Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pip install telepot
- import telepot
- from telepot.loop import MessageLoop
- def handle(msg):
- content_type, chat_type, chat_id = telepot.glance(msg)
- if content_type == 'text':
- command = msg['text']
- # Обработка команды /start
- if command == '/start':
- bot.sendMessage(chat_id, 'Привет! Я бот, давай пообщаемся.')
- else:
- bot.sendMessage(chat_id, 'Я не понимаю эту команду.')
- # Замените 'YOUR_TOKEN' на токен вашего бота
- bot = telepot.Bot('YOUR_TOKEN')
- # Запуск цикла обработки сообщений
- MessageLoop(bot, handle).run_as_thread()
- print('Бот готов к работе.')
- while True:
- pass
Advertisement
Add Comment
Please, Sign In to add comment