2018-01-05 02:59:53 +03:00
|
|
|
====
|
2017-11-20 07:12:31 +03:00
|
|
|
Bots
|
2018-01-05 02:59:53 +03:00
|
|
|
====
|
|
|
|
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-20 13:47:17 +03:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
These examples assume you have read :ref:`accessing-the-full-api`.
|
|
|
|
|
|
|
|
|
2017-11-20 07:12:31 +03:00
|
|
|
Talking to Inline Bots
|
2018-01-05 02:59:53 +03:00
|
|
|
**********************
|
2017-11-20 07:12:31 +03:00
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
You can query an inline bot, such as `@VoteBot`__ (note, *query*,
|
|
|
|
not *interact* with a voting message), by making use of the
|
|
|
|
`GetInlineBotResultsRequest`__ request:
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from telethon.tl.functions.messages import GetInlineBotResultsRequest
|
|
|
|
|
|
|
|
bot_results = client(GetInlineBotResultsRequest(
|
|
|
|
bot, user_or_chat, 'query', ''
|
|
|
|
))
|
|
|
|
|
|
|
|
And you can select any of their results by using
|
|
|
|
`SendInlineBotResultRequest`__:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from telethon.tl.functions.messages import SendInlineBotResultRequest
|
|
|
|
|
|
|
|
client(SendInlineBotResultRequest(
|
|
|
|
get_input_peer(user_or_chat),
|
|
|
|
obtained_query_id,
|
|
|
|
obtained_str_id
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
Talking to Bots with special reply markup
|
2018-01-05 02:59:53 +03:00
|
|
|
*****************************************
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
To interact with a message that has a special reply markup, such as
|
2018-01-05 02:59:53 +03:00
|
|
|
`@VoteBot`__ polls, you would use `GetBotCallbackAnswerRequest`__:
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from telethon.tl.functions.messages import GetBotCallbackAnswerRequest
|
|
|
|
|
|
|
|
client(GetBotCallbackAnswerRequest(
|
|
|
|
user_or_chat,
|
|
|
|
msg.id,
|
|
|
|
data=msg.reply_markup.rows[wanted_row].buttons[wanted_button].data
|
|
|
|
))
|
|
|
|
|
2018-01-05 02:59:53 +03:00
|
|
|
It's a bit verbose, but it has all the information you would need to
|
2017-11-20 07:12:31 +03:00
|
|
|
show it visually (button rows, and buttons within each row, each with
|
|
|
|
its own data).
|
|
|
|
|
|
|
|
__ https://t.me/vote
|
|
|
|
__ https://lonamiwebs.github.io/Telethon/methods/messages/get_inline_bot_results.html
|
|
|
|
__ https://lonamiwebs.github.io/Telethon/methods/messages/send_inline_bot_result.html
|
|
|
|
__ https://lonamiwebs.github.io/Telethon/methods/messages/get_bot_callback_answer.html
|
2018-01-05 02:59:53 +03:00
|
|
|
__ https://t.me/vote
|