Fix get_pinned_message in Chat

Closes #1458.
This commit is contained in:
Lonami Exo 2020-05-17 09:35:44 +02:00
parent 856538635d
commit 29eb90e503

View File

@ -1,5 +1,5 @@
from .common import EventBuilder, EventCommon, name_inner_event
from .. import utils
from .. import utils, helpers
from ..tl import types, functions
@ -261,17 +261,8 @@ class ChatAction(EventBuilder):
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]
))
try:
self._pinned_message = next(
x for x in r.messages
if isinstance(x, types.Message)
and x.id == self._pinned_message
)
except StopIteration:
pass
self._pinned_message = await self._client.get_messages(
self._input_chat, ids=self._pinned_message)
if isinstance(self._pinned_message, types.Message):
return self._pinned_message