init commit

This commit is contained in:
2021-09-05 11:45:55 +02:00
commit 8f7ac550b7
+24
View File
@@ -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()