1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
19+ import logging
1920from datetime import datetime
2021from typing import AsyncGenerator , BinaryIO , List , Optional , Union
2122
2425
2526from ..object import Object
2627
28+ log = logging .getLogger (__name__ )
29+
2730
2831class Chat (Object ):
2932 """A chat.
@@ -44,9 +47,6 @@ class Chat(Object):
4447 is_min (``bool``, *optional*):
4548 True, if this chat have reduced set of fields.
4649
47- is_verified (``bool``, *optional*):
48- True, if this chat has been verified by Telegram. Supergroups, channels and bots only.
49-
5050 is_members_hidden (``bool``, *optional*):
5151 True, if the chat members are hidden.
5252
@@ -60,12 +60,6 @@ class Chat(Object):
6060 is_admin (``bool``, *optional*):
6161 True, if the current user is admin. Supergroups, channels and groups only.
6262
63- is_scam (``bool``, *optional*):
64- True, if this chat has been flagged for scam.
65-
66- is_fake (``bool``, *optional*):
67- True, if this chat has been flagged for impersonation.
68-
6963 is_deactivated (``bool``, *optional*):
7064 True, if this chat has been flagged for deactivated.
7165
@@ -99,6 +93,9 @@ class Chat(Object):
9993 is_paid_reactions_available (``bool``, *optional*):
10094 True, if paid reactions enabled in this chat.
10195
96+ verification_status (:obj:`~pyrogram.types.VerificationStatus`, *optional*):
97+ Contains information about verification status of a chat.
98+
10299 can_send_gift (``bool``, *optional*):
103100 True, if the user can send a gift to the supergroup or channel using :meth:`~pyrogram.Client.send_gift` or :meth:`~pyrogram.Client.transfer_gift`.
104101
@@ -486,13 +483,10 @@ def __init__(
486483 is_forum : Optional [bool ] = None ,
487484 is_direct_messages_group : Optional [bool ] = None ,
488485 is_min : Optional [bool ] = None ,
489- is_verified : Optional [bool ] = None ,
490486 is_members_hidden : Optional [bool ] = None ,
491487 is_restricted : Optional [bool ] = None ,
492488 is_creator : Optional [bool ] = None ,
493489 is_admin : Optional [bool ] = None ,
494- is_scam : Optional [bool ] = None ,
495- is_fake : Optional [bool ] = None ,
496490 is_deactivated : Optional [bool ] = None ,
497491 is_support : Optional [bool ] = None ,
498492 is_stories_hidden : Optional [bool ] = None ,
@@ -504,6 +498,7 @@ def __init__(
504498 is_call_not_empty : Optional [bool ] = None ,
505499 is_public : Optional [bool ] = None ,
506500 is_paid_reactions_available : Optional [bool ] = None ,
501+ verification_status : Optional ["types.VerificationStatus" ] = None ,
507502 can_send_gift : Optional [bool ] = None ,
508503 title : Optional [str ] = None ,
509504 username : Optional [str ] = None ,
@@ -615,13 +610,10 @@ def __init__(
615610 self .is_forum = is_forum
616611 self .is_direct_messages_group = is_direct_messages_group
617612 self .is_min = is_min
618- self .is_verified = is_verified
619613 self .is_members_hidden = is_members_hidden
620614 self .is_restricted = is_restricted
621615 self .is_creator = is_creator
622616 self .is_admin = is_admin
623- self .is_scam = is_scam
624- self .is_fake = is_fake
625617 self .is_deactivated = is_deactivated
626618 self .is_support = is_support
627619 self .is_stories_hidden = is_stories_hidden
@@ -633,6 +625,7 @@ def __init__(
633625 self .is_call_not_empty = is_call_not_empty
634626 self .is_public = is_public
635627 self .is_paid_reactions_available = is_paid_reactions_available
628+ self .verification_status = verification_status
636629 self .can_send_gift = can_send_gift
637630 self .title = title
638631 self .username = username
@@ -737,6 +730,32 @@ def __init__(
737730 self .accepted_gift_types = accepted_gift_types
738731 self .raw = raw
739732
733+ # region Deprecated
734+ # TODO: Remove later
735+
736+ @property
737+ def is_verified (self ) -> Optional [bool ]:
738+ log .warning (
739+ "`chat.is_verified` is deprecated and will be removed in future updates. Use `chat.verification_status.is_verified` instead."
740+ )
741+ return getattr (self .verification_status , "is_verified" , None )
742+
743+ @property
744+ def is_scam (self ) -> Optional [bool ]:
745+ log .warning (
746+ "`chat.is_scam` is deprecated and will be removed in future updates. Use `chat.verification_status.is_scam` instead."
747+ )
748+ return getattr (self .verification_status , "is_scam" , None )
749+
750+ @property
751+ def is_fake (self ) -> Optional [bool ]:
752+ log .warning (
753+ "`chat.is_fake` is deprecated and will be removed in future updates. Use `chat.verification_status.is_fake` instead."
754+ )
755+ return getattr (self .verification_status , "is_fake" , None )
756+
757+ # endregion
758+
740759 @staticmethod
741760 def _parse_user_chat (client , user : "raw.types.User" ) -> Optional ["Chat" ]:
742761 if user is None or isinstance (user , raw .types .UserEmpty ):
@@ -747,14 +766,12 @@ def _parse_user_chat(client, user: "raw.types.User") -> Optional["Chat"]:
747766 return Chat (
748767 id = peer_id ,
749768 type = enums .ChatType .BOT if user .bot else enums .ChatType .PRIVATE ,
750- is_verified = user .verified ,
751769 is_restricted = user .restricted ,
752- is_scam = user .scam ,
753- is_fake = user .fake ,
754770 is_support = user .support ,
755771 is_stories_hidden = user .stories_hidden ,
756772 is_stories_unavailable = user .stories_unavailable ,
757773 is_business_bot = user .bot_business ,
774+ verification_status = types .VerificationStatus ._parse (user ),
758775 username = user .username or (user .usernames [0 ].username if user .usernames else None ),
759776 usernames = types .List ([types .Username ._parse (r ) for r in user .usernames ]) or None ,
760777 first_name = user .first_name ,
@@ -841,16 +858,14 @@ def _parse_channel_chat(client, channel: "raw.types.Channel") -> Optional["Chat"
841858 is_forum = channel .forum ,
842859 is_direct_messages_group = channel .monoforum ,
843860 is_min = channel .min ,
844- is_verified = channel .verified ,
845861 is_restricted = channel .restricted ,
846862 is_creator = channel .creator ,
847863 is_admin = True if channel .admin_rights else None ,
848- is_scam = channel .scam ,
849- is_fake = channel .fake ,
850864 is_stories_hidden = channel .stories_hidden ,
851865 is_stories_unavailable = channel .stories_unavailable ,
852866 is_call_active = channel .call_active ,
853867 is_call_not_empty = channel .call_not_empty ,
868+ verification_status = types .VerificationStatus ._parse (channel ),
854869 title = channel .title ,
855870 username = channel .username or (channel .usernames [0 ].username if channel .usernames else None ),
856871 usernames = types .List ([types .Username ._parse (r ) for r in usernames ]) or None ,
@@ -883,7 +898,7 @@ def _parse(
883898 users : dict ,
884899 chats : dict ,
885900 is_chat : bool
886- ) -> "Chat" :
901+ ) -> Optional [ "Chat" ] :
887902 from_id = utils .get_raw_peer_id (message .from_id )
888903 peer_id = utils .get_raw_peer_id (message .peer_id )
889904 chat_id = (peer_id or from_id ) if is_chat else (from_id or peer_id )
@@ -1153,11 +1168,9 @@ def _parse_preview(client, chat_invite: "raw.types.ChatInvite") -> "Chat":
11531168 enums .ChatType .CHANNEL if chat_invite .broadcast else
11541169 enums .ChatType .GROUP
11551170 ),
1156- is_verified = chat_invite .verified ,
1157- is_scam = chat_invite .scam ,
1158- is_fake = chat_invite .fake ,
11591171 is_public = chat_invite .public ,
11601172 is_preview = True ,
1173+ verification_status = types .VerificationStatus ._parse (chat_invite ),
11611174 title = chat_invite .title ,
11621175 photo = types .Photo ._parse (client , chat_invite .photo ),
11631176 members_count = chat_invite .participants_count ,
0 commit comments