Telegram bot: How to get chosen inline result -


i'm sending inlinequeryresultarticle clients , i'm wondering how chosen result , it's data (like result_id,...).

here code send results:

token = 'bot token' bot = telegram.bot(token) updater = updater(token) dispatcher = updater.dispatcher  def get_inline_results(bot, update):     query = update.inline_query.query     results = list()      results.append(inlinequeryresultarticle(id='1000',                                             title="book 1",                                             description='description of book, author ...',                                             thumb_url='https://fakeimg.pl/100/?text=book%201',                                             input_message_content=inputtextmessagecontent(                                                 'chosen book:')))      results.append(inlinequeryresultarticle(id='1001',                                             title="book 2",                                             description='description of book, author...',                                             thumb_url='https://fakeimg.pl/300/?text=book%202',                                             input_message_content=inputtextmessagecontent(                                                 'chosen book:')                                             ))      update.inline_query.answer(results)   inline_query_handler = inlinequeryhandler(get_inline_results) dispatcher.add_handler(inline_query_handler) 

i'm looking method on_inline_chosen(data) id of chosen item. (1000 or 1001 snippet above) , send appropriate response user.

ok, got answer here

handling user chosen result:

from telegram.ext import choseninlineresulthandler  def on_result_chosen(bot, update):     print(update.to_dict())     result = update.chosen_inline_result     result_id = result.result_id     query = result.query     user = result.from_user.id     print(result_id)     print(user)     print(query)     print(result.inline_message_id)     bot.send_message(user, text='fetching book data id:' + result_id)   result_chosen_handler = choseninlineresulthandler(on_result_chosen) dispatcher.add_handler(result_chosen_handler) 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -