From ca2537941c806939dfab8137d077f34d22490f9c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 22 Oct 2019 20:35:08 +0200 Subject: [PATCH] Fix sending albums in conversations --- telethon/tl/custom/conversation.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/telethon/tl/custom/conversation.py b/telethon/tl/custom/conversation.py index 767ec95d..e141004f 100644 --- a/telethon/tl/custom/conversation.py +++ b/telethon/tl/custom/conversation.py @@ -72,12 +72,14 @@ class Conversation(ChatGetter): for `telethon.client.messages.MessageMethods.send_message` with ``entity`` already set. """ - message = await self._client.send_message( + sent = await self._client.send_message( self._input_chat, *args, **kwargs) - self._outgoing.add(message.id) - self._last_outgoing = message.id - return message + # Albums will be lists, so handle that + ms = sent if isinstance(sent, list) else (sent,) + self._outgoing.update(m.id for m in ms) + self._last_outgoing = ms[-1].id + return sent async def send_file(self, *args, **kwargs): """ @@ -85,12 +87,14 @@ class Conversation(ChatGetter): for `telethon.client.uploads.UploadMethods.send_file` with ``entity`` already set. """ - message = await self._client.send_file( + sent = await self._client.send_file( self._input_chat, *args, **kwargs) - self._outgoing.add(message.id) - self._last_outgoing = message.id - return message + # Albums will be lists, so handle that + ms = sent if isinstance(sent, list) else (sent,) + self._outgoing.update(m.id for m in ms) + self._last_outgoing = ms[-1].id + return sent def mark_read(self, message=None): """