2017-08-15 3 views
2

(...、result_idにように)私はクライアントにInlineQueryResultArticleを送っていると私が選択した結果を取得する方法を疑問に思うし、それのデータです。ここ電報ボット:どのように選択を取得するには、インライン結果

は、結果を送信するためのコードです:

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) 

私が選択したアイテムのIDを取得するためにon_inline_chosen(data)のような方法を探しています。次に、(上記のスニペット用1000 or 1001)、ユーザに適切な応答を送信します。

答えて

2

OKを取得します、私は、ユーザー選択した結果の処理here

から私の答えを得た:

​​
4

あなたは@BotFather/setinlinefeedbackを設定する必要があり、その後、この更新プログラムに

+0

おかげで、しかし、私はよ() 'コードでon_inline_result_selected'実装する方法を疑問に思います。 –

関連する問題