From 216805d62dd8d71580dc87181de2be225265a18f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 14 Aug 2018 18:41:13 +0200 Subject: [PATCH] Fix telethon.sync for custom.Conversation --- telethon/tl/custom/conversation.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/telethon/tl/custom/conversation.py b/telethon/tl/custom/conversation.py index 0f6579c2..38ca9006 100644 --- a/telethon/tl/custom/conversation.py +++ b/telethon/tl/custom/conversation.py @@ -105,7 +105,7 @@ class Conversation(ChatGetter): return self._client.send_read_acknowledge( self._input_chat, max_id=message) - def get_response(self, message=None, *, timeout=None): + async def get_response(self, message=None, *, timeout=None): """ Returns a coroutine that will resolve once a response arrives. @@ -118,18 +118,18 @@ class Conversation(ChatGetter): If present, this `timeout` will override the per-action timeout defined for the conversation. """ - return self._get_message( + return await self._get_message( message, self._response_indices, self._pending_responses, timeout, lambda x, y: True ) - def get_reply(self, message=None, *, timeout=None): + async def get_reply(self, message=None, *, timeout=None): """ Returns a coroutine that will resolve once a reply (that is, a message being a reply) arrives. The arguments are the same as those for `get_response`. """ - return self._get_message( + return await self._get_message( message, self._reply_indices, self._pending_replies, timeout, lambda x, y: x.reply_to_msg_id == y ) @@ -185,7 +185,7 @@ class Conversation(ChatGetter): pending[target_id] = future return self._get_result(future, start_time, timeout) - def get_edit(self, message=None, *, timeout=None): + async def get_edit(self, message=None, *, timeout=None): """ Awaits for an edit after the last message to arrive. The arguments are the same as those for `get_response`. @@ -208,9 +208,9 @@ class Conversation(ChatGetter): # Otherwise the next incoming response will be the one to use future = asyncio.Future() self._pending_edits[target_id] = future - return self._get_result(future, start_time, timeout) + return await self._get_result(future, start_time, timeout) - def wait_read(self, message=None, *, timeout=None): + async def wait_read(self, message=None, *, timeout=None): """ Awaits for the sent message to be read. Note that receiving a response doesn't imply the message was read, and this action @@ -227,9 +227,9 @@ class Conversation(ChatGetter): return self._pending_reads[target_id] = future - return self._get_result(future, start_time, timeout) + return await self._get_result(future, start_time, timeout) - def wait_event(self, event, *, timeout=None): + async def wait_event(self, event, *, timeout=None): """ Waits for a custom event to occur. Timeouts still apply. @@ -268,7 +268,7 @@ class Conversation(ChatGetter): del self._custom[counter] self._custom[counter] = (event, future, False) - return result() + return await result() async def _check_custom(self, built, update): # TODO This code is quite much a copy paste of registering events