mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Expose entity parameter in client.inline_query
Some bots, such as @gamee, use this to determine the type of results to return (and "disable" themselves in channels).
This commit is contained in:
@@ -25,10 +25,11 @@ class InlineResult:
|
||||
CONTACT = 'contact'
|
||||
GAME = 'game'
|
||||
|
||||
def __init__(self, client, original, query_id=None):
|
||||
def __init__(self, client, original, query_id=None, *, entity=None):
|
||||
self._client = client
|
||||
self.result = original
|
||||
self._query_id = query_id
|
||||
self._entity = entity
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
@@ -97,7 +98,7 @@ class InlineResult:
|
||||
elif isinstance(self.result, types.BotInlineMediaResult):
|
||||
return self.result.document
|
||||
|
||||
async def click(self, entity, reply_to=None,
|
||||
async def click(self, entity=None, reply_to=None,
|
||||
silent=False, clear_draft=False, hide_via=False):
|
||||
"""
|
||||
Clicks this result and sends the associated `message`.
|
||||
@@ -123,7 +124,13 @@ class InlineResult:
|
||||
Whether the "via @bot" should be hidden or not.
|
||||
Only works with certain bots (like @bing or @gif).
|
||||
"""
|
||||
entity = await self._client.get_input_entity(entity)
|
||||
if entity:
|
||||
entity = await self._client.get_input_entity(entity)
|
||||
elif self._entity:
|
||||
entity = self._entity
|
||||
else:
|
||||
raise ValueError('You must provide the entity where the result should be sent to')
|
||||
|
||||
reply_id = None if reply_to is None else utils.get_message_id(reply_to)
|
||||
req = functions.messages.SendInlineBotResultRequest(
|
||||
peer=entity,
|
||||
|
Reference in New Issue
Block a user