This repository has been archived on 2024-04-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
telegram-bot/bot.py
T
2021-09-05 11:45:55 +02:00

24 lines
730 B
Python

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()