Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telegram import Update, Bot
- from telegram.ext import Updater, CommandHandler, Filters, MessageHandler
- from config import TOKEN
- bot = Bot(token=TOKEN)
- updater = Updater(token=TOKEN)
- dispatcher = updater.dispatcher
- def start(update, context):
- arg = context.args
- if not arg:
- context.bot.send_message(update.effective_chat.id, "Привет")
- else:
- context.bot.send_message(update.effective_chat.id, f"{' '.join(arg)}")
- def info(update, context):
- context.bot.send_message(update.effective_chat.id, "I'm Batman")
- def message(update, context):
- text = update.message.text
- if text.lower() == 'привет':
- context.bot.send_message(update.effective_chat.id, 'И тебе привет..')
- else:
- context.bot.send_message(update.effective_chat.id, 'я тебя не понимаю')
- def unknown(update, context):
- context.bot.send_message(update.effective_chat.id, f'Шо сказал, не пойму')
- start_handler = CommandHandler('start', start)#/start фразочка
- info_handler = CommandHandler('info', info)#/info
- message_handler = MessageHandler(Filters.text, message)
- unknown_handler = MessageHandler(Filters.command, unknown) #/game
- dispatcher.add_handler(start_handler)
- dispatcher.add_handler(info_handler)
- dispatcher.add_handler(unknown_handler)
- dispatcher.add_handler(message_handler)
- print('server started')
- updater.start_polling()
- updater.idle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement