From 2439404ad1714db9571ff15ca406823a6ed9f515 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 28 Nov 2020 16:49:39 +0100 Subject: [PATCH] Include service messages for new pins in ChatAction again --- telethon/events/chataction.py | 12 ++++++++---- telethon/version.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/telethon/events/chataction.py b/telethon/events/chataction.py index cf787856..6427f85a 100644 --- a/telethon/events/chataction.py +++ b/telethon/events/chataction.py @@ -31,12 +31,15 @@ class ChatAction(EventBuilder): """ @classmethod def build(cls, update, others=None, self_id=None): - if isinstance(update, types.UpdatePinnedChannelMessages): + # Rely on specific pin updates for unpins, but otherwise ignore them + # for new pins (we'd rather handle the new service message with pin, + # so that we can act on that message'). + if isinstance(update, types.UpdatePinnedChannelMessages) and not update.pinned: return cls.Event(types.PeerChannel(update.channel_id), pin_ids=update.messages, pin=update.pinned) - elif isinstance(update, types.UpdatePinnedMessages): + elif isinstance(update, types.UpdatePinnedMessages) and not update.pinned: return cls.Event(update.peer, pin_ids=update.messages, pin=update.pinned) @@ -107,8 +110,9 @@ class ChatAction(EventBuilder): return cls.Event(msg, users=msg.from_id, new_photo=True) - # Handled by specific updates - # elif isinstance(action, types.MessageActionPinMessage) and msg.reply_to: + elif isinstance(action, types.MessageActionPinMessage) and msg.reply_to: + return cls.Event(msg, + pin_ids=[msg.reply_to_msg_id]) class Event(EventCommon): """ diff --git a/telethon/version.py b/telethon/version.py index 76bdba70..dbd61bac 100644 --- a/telethon/version.py +++ b/telethon/version.py @@ -1,3 +1,3 @@ # Versions should comply with PEP440. # This line is parsed in setup.py: -__version__ = '1.18.1' +__version__ = '1.18.2'