KurimuzonAkuma / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
321 stars 90 forks source link

Fix: edge-case when pinned action is `MessageActionHistoryClear` #49

Closed Danipulok closed 5 months ago

Danipulok commented 5 months ago

Fix edge-case when pinned action message is MessageActionHistoryClear.

What I received inside raw action:

action <class 'pyrogram.raw.types.channel_admin_log_event_action_update_pinned.ChannelAdminLogEventActionUpdatePinned'> 
pyrogram.raw.types.ChannelAdminLogEventActionUpdatePinned(
  message=pyrogram.raw.types.MessageService(
    id=1337, 
    peer_id=pyrogram.raw.types.PeerChannel(channel_id=1337), 
    date=1714411215, 
    action=pyrogram.raw.types.MessageActionHistoryClear(), 
    out=True, 
    mentioned=False, 
    media_unread=False, 
    silent=False, 
    post=False, 
    legacy=False, 
    from_id=pyrogram.raw.types.PeerUser(user_id=1337)
  )
)

Error before following commit:

Traceback (most recent call last):
  File "D:\Code\Personal\userbot\scripts\testing.py", line 57, in <module>
    loop.run_until_complete(main())
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\Code\Personal\userbot\scripts\testing.py", line 41, in main
    async for action in client.get_chat_event_log(chat_id):
  File "D:\Code\Personal\userbot\.venv\lib\site-packages\pyrogram\methods\chats\get_chat_event_log.py", line 104, in get_chat_event_log
    yield await types.ChatEvent._parse(self, event, r.users, r.chats)
  File "D:\Code\Personal\userbot\.venv\lib\site-packages\pyrogram\types\user_and_chats\chat_event.py", line 436, in _parse
    if message.pinned:
AttributeError: 'MessageService' object has no attribute 'pinned'

Process finished with exit code 1