Rely on types.UpdateChatPinnedMessage for chat unpins

Fixes #1405, probably.
This commit is contained in:
Lonami Exo 2020-04-27 21:16:45 +02:00
parent 71ed1564cb
commit 7f3aa43ad4

View File

@ -38,6 +38,10 @@ class ChatAction(EventBuilder):
return cls.Event(types.PeerChannel(update.channel_id), return cls.Event(types.PeerChannel(update.channel_id),
unpin=True) unpin=True)
elif isinstance(update, types.UpdateChatPinnedMessage) and update.id == 0:
return cls.Event(types.PeerChat(update.chat_id),
unpin=True)
elif isinstance(update, types.UpdateChatParticipantAdd): elif isinstance(update, types.UpdateChatParticipantAdd):
return cls.Event(types.PeerChat(update.chat_id), return cls.Event(types.PeerChat(update.chat_id),
added_by=update.inviter_id or True, added_by=update.inviter_id or True,
@ -104,8 +108,9 @@ class ChatAction(EventBuilder):
return cls.Event(msg, return cls.Event(msg,
users=msg.from_id, users=msg.from_id,
new_photo=True) new_photo=True)
elif isinstance(action, types.MessageActionPinMessage): elif isinstance(action, types.MessageActionPinMessage) and msg.reply_to_msg_id:
# Telegram always sends this service message for new pins # Seems to not be reliable on unpins, but when pinning
# we prefer this because we know who caused it.
return cls.Event(msg, return cls.Event(msg,
users=msg.from_id, users=msg.from_id,
new_pin=msg.reply_to_msg_id) new_pin=msg.reply_to_msg_id)