diff --git a/pyrogram/enums/chat_event_action.py b/pyrogram/enums/chat_event_action.py index eff86f37..921cb90d 100644 --- a/pyrogram/enums/chat_event_action.py +++ b/pyrogram/enums/chat_event_action.py @@ -123,6 +123,10 @@ class ChatEventAction(AutoName): MESSAGE_UNPINNED = auto() "a message has been unpinned (see ``unpinned_message``)" + MESSAGE_PIN_CHANGED = auto() + "a message has been pinned or unpinned but actual message is not received" + "should never be used in end-user code, only for correct parsing" + CREATED_FORUM_TOPIC = auto() "a new forum topic has been created (see `created_forum_topic`)" diff --git a/pyrogram/types/user_and_chats/chat_event.py b/pyrogram/types/user_and_chats/chat_event.py index 9faea6a0..ef76e139 100644 --- a/pyrogram/types/user_and_chats/chat_event.py +++ b/pyrogram/types/user_and_chats/chat_event.py @@ -433,12 +433,14 @@ class ChatEvent(Object): elif isinstance(action, raw.types.ChannelAdminLogEventActionUpdatePinned): message = action.message - if message.pinned: + if isinstance(message, raw.types.Message) and message.pinned: pinned_message = await types.Message._parse(client, message, users, chats) action = enums.ChatEventAction.MESSAGE_PINNED - else: + elif isinstance(message, raw.types.Message) and not message.pinned: unpinned_message = await types.Message._parse(client, message, users, chats) action = enums.ChatEventAction.MESSAGE_UNPINNED + else: + action = enums.ChatEventAction.MESSAGE_PIN_CHANGED elif isinstance(action, raw.types.ChannelAdminLogEventActionExportedInviteEdit): old_invite_link = types.ChatInviteLink._parse(client, action.prev_invite, users)