Stop using await with properties

This commit is contained in:
Lonami Exo 2018-06-25 11:38:56 +02:00
parent 0d09f9d8c1
commit 410518aa65
3 changed files with 9 additions and 6 deletions

View File

@ -171,7 +171,7 @@ class ChatAction(EventBuilder):
``entity`` already set.
"""
return await self._client.send_message(
await self.input_chat, *args, **kwargs)
await self.get_input_chat(), *args, **kwargs)
async def reply(self, *args, **kwargs):
"""
@ -186,7 +186,7 @@ class ChatAction(EventBuilder):
kwargs['reply_to'] = self.action_message.id
return await self._client.send_message(
await self.input_chat, *args, **kwargs)
await self.get_input_chat(), *args, **kwargs)
async def delete(self, *args, **kwargs):
"""
@ -202,7 +202,9 @@ class ChatAction(EventBuilder):
return
return await self._client.delete_messages(
await self.input_chat, [self.action_message], *args, **kwargs)
await self.get_input_chat(), [self.action_message],
*args, **kwargs
)
async def get_pinned_message(self):
"""
@ -212,7 +214,8 @@ class ChatAction(EventBuilder):
if self._pinned_message == 0:
return None
if isinstance(self._pinned_message, int) and await self.input_chat:
if isinstance(self._pinned_message, int)\
and await self.get_input_chat():
r = await self._client(functions.channels.GetMessagesRequest(
self._input_chat, [self._pinned_message]
))

View File

@ -97,7 +97,7 @@ class MessageRead(EventBuilder):
was read instead checking if it's in here.
"""
if self._messages is None:
chat = await self.input_chat
chat = await self.get_input_chat()
if not chat:
self._messages = []
else:

View File

@ -675,7 +675,7 @@ class Message:
if sum(int(x is not None) for x in (i, text, filter)) >= 2:
raise ValueError('You can only set either of i, text or filter')
if not await self.buttons:
if not await self.get_buttons():
return # Accessing the property sets self._buttons[_flat]
if text is not None: