2019-05-03 22:37:27 +03:00
|
|
|
import typing
|
|
|
|
|
|
|
|
from .. import hints
|
2018-08-01 02:06:47 +03:00
|
|
|
from ..tl import types, functions, custom
|
|
|
|
|
2019-05-03 22:37:27 +03:00
|
|
|
if typing.TYPE_CHECKING:
|
|
|
|
from .telegramclient import TelegramClient
|
|
|
|
|
2018-08-01 02:06:47 +03:00
|
|
|
|
2019-06-24 18:48:46 +03:00
|
|
|
class BotMethods:
|
2019-05-03 22:37:27 +03:00
|
|
|
async def inline_query(
|
|
|
|
self: 'TelegramClient',
|
2019-05-08 18:16:09 +03:00
|
|
|
bot: 'hints.EntityLike',
|
2019-05-03 22:37:27 +03:00
|
|
|
query: str,
|
|
|
|
*,
|
|
|
|
offset: str = None,
|
2019-05-08 18:16:09 +03:00
|
|
|
geo_point: 'types.GeoPoint' = None) -> custom.InlineResults:
|
2018-08-01 02:06:47 +03:00
|
|
|
"""
|
2019-05-06 12:38:26 +03:00
|
|
|
Makes an inline query to the specified bot (e.g. ``@vote New Poll``).
|
2018-08-01 02:06:47 +03:00
|
|
|
|
2019-05-20 12:38:26 +03:00
|
|
|
Arguments
|
2018-08-01 02:06:47 +03:00
|
|
|
bot (`entity`):
|
|
|
|
The bot entity to which the inline query should be made.
|
|
|
|
|
|
|
|
query (`str`):
|
|
|
|
The query that should be made to the bot.
|
|
|
|
|
|
|
|
offset (`str`, optional):
|
|
|
|
The string offset to use for the bot.
|
|
|
|
|
|
|
|
geo_point (:tl:`GeoPoint`, optional)
|
|
|
|
The geo point location information to send to the bot
|
|
|
|
for localised results. Available under some bots.
|
|
|
|
|
2019-05-20 12:38:26 +03:00
|
|
|
Returns
|
2018-08-01 02:06:47 +03:00
|
|
|
A list of `custom.InlineResult
|
|
|
|
<telethon.tl.custom.inlineresult.InlineResult>`.
|
2019-05-09 13:24:37 +03:00
|
|
|
|
2019-05-20 12:38:26 +03:00
|
|
|
Example
|
2019-05-09 13:24:37 +03:00
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
# Make an inline query to @like
|
|
|
|
results = client.inline_query('like', 'Do you like Telethon?')
|
|
|
|
|
|
|
|
# Send the first result to some chat
|
|
|
|
message = results[0].click('TelethonOffTopic')
|
2018-08-01 02:06:47 +03:00
|
|
|
"""
|
|
|
|
bot = await self.get_input_entity(bot)
|
|
|
|
result = await self(functions.messages.GetInlineBotResultsRequest(
|
|
|
|
bot=bot,
|
|
|
|
peer=types.InputPeerEmpty(),
|
|
|
|
query=query,
|
|
|
|
offset=offset or '',
|
|
|
|
geo_point=geo_point
|
|
|
|
))
|
|
|
|
|
2018-08-03 00:31:51 +03:00
|
|
|
return custom.InlineResults(self, result)
|