nickoala / telepot

Python framework for Telegram Bot API
MIT License
2.43k stars 474 forks source link

on query after another #464

Open eenvid opened 5 years ago

eenvid commented 5 years ago

hi I want to run a query after another query.

` def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) keyboard = InlineKeyboardMarkup(inline_keyboard=[ [InlineKeyboardButton(text='ISO', callback_data='iso')], [InlineKeyboardButton(text='MAKRO', callback_data='makro')],
]) bot.sendMessage(chat_id, 'please select one', reply_markup=keyboard)

def menu(msg): query_id, from_id, query_data = telepot.glance(msg, flavor='callback_query')

if  query_data=='makro':
     keyboard = InlineKeyboardMarkup(inline_keyboard=[
               [InlineKeyboardButton(text='number 1', callback_data='1')],
               [InlineKeyboardButton(text='number 2', callback_data='2')],   
           ])
    bot.sendMessage(from_id,'please select one, reply_markup=keyboard)

if  query_data=='iso':
         keyboard = InlineKeyboardMarkup(inline_keyboard=[
               [InlineKeyboardButton(text='number 3', callback_data='3')],
               [InlineKeyboardButton(text='number 4', callback_data='4')],   
           ])
    bot.sendMessage(from_id,'please select one, reply_markup=keyboard)

bot = telepot.Bot(TOKEN) MessageLoop(bot, {'chat': on_chat_message, 'callback_query': menu}).run_as_thread()

`

And according to what the user chooses in the second query, one number will be displayed.

I wrote the code above and I'll go to the second menu stage. But after that, I do not know what to do, so the program proceeds according to the user's choice in the second menu