diff --git a/pyrogram/types/user_and_chats/chat_invite_link.py b/pyrogram/types/user_and_chats/chat_invite_link.py index 7aaa56a8..59f6315b 100644 --- a/pyrogram/types/user_and_chats/chat_invite_link.py +++ b/pyrogram/types/user_and_chats/chat_invite_link.py @@ -18,6 +18,7 @@ from datetime import datetime from typing import Dict +from typing import Optional import pyrogram from pyrogram import raw, utils @@ -103,7 +104,10 @@ class ChatInviteLink(Object): client: "pyrogram.Client", invite: "raw.base.ExportedChatInvite", users: Dict[int, "raw.types.User"] = None - ) -> "ChatInviteLink": + ) -> Optional["ChatInviteLink"]: + if not isinstance(invite, raw.types.ChatInviteExported): + return None + creator = ( types.User._parse(client, users[invite.admin_id]) if users is not None