24 lines
730 B
Python
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() |