2017-08-15 84 views
2

我發送InlineQueryResultArticle給客戶,我想知道如何得到選擇的結果和它的數據(如result_id,...)。電報機器人:如何得到選擇的內聯結果

這裏是把結果發送代碼:

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 this 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 the 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) 

我正在尋找像on_inline_chosen(data)一個方法來獲得所選擇項的ID。 (1000 or 1001上面的代碼片段),然後發送適當的響應給用戶。

回答

2

OK,我得到了我的答案從here

處理用戶選擇的結果:

​​
4

你應該@BotFather設置/setinlinefeedback,那麼你會得到此更新

+0

感謝,但我想知道如何在代碼中實現'on_inline_result_selected()'。 –

相關問題