53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
# Work in Progress
|
|
# Api-Key: 5228016873:AAGFrh0P6brag7oD3gxXjCh5gnLLE8JMvMs
|
|
# text bot at t.me/projektaktienbot
|
|
# API Documentation https://core.telegram.org/bots/api
|
|
# Code examples https://github.com/eternnoir/pyTelegramBotAPI#getting-started
|
|
import os
|
|
|
|
import telebot
|
|
import time
|
|
import sys
|
|
import logging
|
|
from telebot import types
|
|
|
|
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
|
|
|
|
|
@bot.message_handler(commands=['start', 'help'])
|
|
def send_welcome(message):
|
|
bot.reply_to(message, "Thank you for using this bot")
|
|
|
|
|
|
@bot.message_handler(func=lambda message: True)
|
|
def echo_all(message):
|
|
answer = message.text + ' ID: ' + str(message.from_user.id)
|
|
bot.reply_to(message, answer)
|
|
|
|
|
|
telebot.logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
@bot.inline_handler(lambda query: query.query == 'text')
|
|
def query_text(inline_query):
|
|
try:
|
|
r = types.InlineQueryResultArticle('1', 'Result1', types.InputTextMessageContent('hi'))
|
|
r2 = types.InlineQueryResultArticle('2', 'Result2', types.InputTextMessageContent('hi'))
|
|
bot.answer_inline_query(inline_query.id, [r, r2])
|
|
except Exception as e:
|
|
print(e)
|
|
|
|
|
|
def main_loop():
|
|
bot.infinity_polling()
|
|
while 1:
|
|
time.sleep(3)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
main_loop()
|
|
except KeyboardInterrupt:
|
|
print('\nExiting by user request.\n')
|
|
sys.exit(0)
|