Skip to content

Instantly share code, notes, and snippets.

@b0g3r
Created May 9, 2018 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b0g3r/fb43495b97a5685daa1f0cfadd6d93b2 to your computer and use it in GitHub Desktop.
Save b0g3r/fb43495b97a5685daa1f0cfadd6d93b2 to your computer and use it in GitHub Desktop.
import telebot
token = '549970082:AAEJFMftKR9VbC-jyv2O--QbWzriyfFfjI0'
bot = telebot.TeleBot(token)
states = {}
@bot.message_handler(func=lambda m: states.get(m.chat.id, 0) ==0)
def stat0(message):
text = message.text
if text == 'дай мне новости':
response ='вот новости на сегодня'
states[message.chat.id] = 1
else:
response = 'есть вапросы?'
bot.send_message(message.chat.id, response)
@bot.message_handler(func=lambda m: states.get(m.chat.id, 0) ==1)
def state1(message):
import random
text = message.text
if text == 'всё':
states[message.chat.id] = 0
choice=['ммм...', 'хорошо', 'давай по новой']
bot.send_message (message.chat.id,
random.choice(choice))
bot.polling()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment