Skip to content

Commit

Permalink
Include service messages for new pins in ChatAction again
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Nov 28, 2020
1 parent 23fc38f commit 2439404
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions telethon/events/chataction.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ async def handler(event):
"""
@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)
Expand Down Expand Up @@ -107,8 +110,9 @@ def build(cls, update, others=None, self_id=None):
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):
"""
Expand Down
2 changes: 1 addition & 1 deletion telethon/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Versions should comply with PEP440.
# This line is parsed in setup.py:
__version__ = '1.18.1'
__version__ = '1.18.2'

0 comments on commit 2439404

Please sign in to comment.