From a214a4c6311f250fbd0a253c2235614d37e17b24 Mon Sep 17 00:00:00 2001 From: Lonami Date: Tue, 27 Jun 2017 10:29:08 +0200 Subject: [PATCH] Add example on how to interact with reply markups --- Talking-to-inline-bots.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Talking-to-inline-bots.md b/Talking-to-inline-bots.md index 1140c85..2e256af 100644 --- a/Talking-to-inline-bots.md +++ b/Talking-to-inline-bots.md @@ -1,4 +1,4 @@ -You can query an inline bot, such as [@vote](https://t.me/vote), by making use of the [`GetInlineBotResultsRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/get_inline_bot_results.html) request: +You can query an inline bot, such as [@VoteBot](https://t.me/vote) (note, *query*, not *interact* with a voting message), by making use of the [`GetInlineBotResultsRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/get_inline_bot_results.html) request: ```python from telethon.tl.functions.messages import GetInlineBotResultsRequest @@ -8,7 +8,7 @@ bot_results = client.invoke(GetInlineBotResultsRequest( )) ``` -And you can reply to their results by using [`SendInlineBotResultRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/send_inline_bot_result.html): +And you can select any of their results by using [`SendInlineBotResultRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/send_inline_bot_result.html): ```python from telethon.tl.functions.messages import SendInlineBotResultRequest @@ -18,4 +18,20 @@ client.invoke(SendInlineBotResultRequest( obtained_query_id, obtained_str_id )) -``` \ No newline at end of file +``` + +--- + +To interact with a message that has a special reply markup, such as [@VoteBot](https://t.me/vote)'s polls, you would use [`GetBotCallbackAnswerRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/get_bot_callback_answer.html): + +```python +from telethon.tl.functions.messages import GetBotCallbackAnswerRequest + +client.invoke(GetBotCallbackAnswerRequest( + user_or_chat, + msg.id, + data=msg.reply_markup.rows[wanted_row].buttons[wanted_button].data +)) +``` + +It's a bit verbose, but it has all the information you would need to show it visually (button rows, and buttons within each row, each with its own data). \ No newline at end of file