From 8f7ac550b71dd88d3880c3e82ad01b035fe0bc4f Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Sun, 5 Sep 2021 11:45:55 +0200 Subject: [PATCH] init commit --- bot.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bot.py diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..ae727c8 --- /dev/null +++ b/bot.py @@ -0,0 +1,24 @@ +import telegram.ext + +with open('token.txt', 'r') as f: + TOKEN = f.read() + +def start(update, context): + update.message.reply_text('Hi') + +def help(update, context): + update.message.reply_text('i am a chat bot just begin to chat with me') + +def handle_message(update, context): + update.message.reply_text(f'I got {update.message.text}') + print(update.message.text, update.message.chat.username) + +updater = telegram.ext.Updater(TOKEN, use_context=True) +disp = updater.dispatcher + +disp.add_handler(telegram.ext.CommandHandler('start', start)) +disp.add_handler(telegram.ext.CommandHandler('help', help)) +disp.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.text, handle_message)) + +updater.start_polling() +updater.idle() \ No newline at end of file