karen_constantine

Untitled

Nov 12th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. pip install telepot
  2.  
  3. import telepot
  4. from telepot.loop import MessageLoop
  5.  
  6. def handle(msg):
  7. content_type, chat_type, chat_id = telepot.glance(msg)
  8.  
  9. if content_type == 'text':
  10. command = msg['text']
  11. # Обработка команды /start
  12. if command == '/start':
  13. bot.sendMessage(chat_id, 'Привет! Я бот, давай пообщаемся.')
  14. else:
  15. bot.sendMessage(chat_id, 'Я не понимаю эту команду.')
  16.  
  17. # Замените 'YOUR_TOKEN' на токен вашего бота
  18. bot = telepot.Bot('YOUR_TOKEN')
  19.  
  20. # Запуск цикла обработки сообщений
  21. MessageLoop(bot, handle).run_as_thread()
  22.  
  23. print('Бот готов к работе.')
  24.  
  25. while True:
  26. pass
  27.  
Advertisement
Add Comment
Please, Sign In to add comment