diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index bf89ffe7..e7cbdca3 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -502,6 +502,7 @@ def pyrogram_api(): BotInfo ChatColor CollectibleItemInfo + BotVerification """, messages_media=""" Messages & Media @@ -780,7 +781,6 @@ def pyrogram_api(): Message.react Message.translate Message.wait_for_click - UserGift.toggle """, chat=""" Chat diff --git a/pyrogram/types/user_and_chats/__init__.py b/pyrogram/types/user_and_chats/__init__.py index 74483aa3..77eb5845 100644 --- a/pyrogram/types/user_and_chats/__init__.py +++ b/pyrogram/types/user_and_chats/__init__.py @@ -18,6 +18,7 @@ # along with Pyrofork. If not, see . from .birthday import Birthday +from .bot_verification import BotVerification from .business_info import BusinessInfo from .business_message import BusinessMessage from .business_recipients import BusinessRecipients @@ -62,6 +63,7 @@ from .video_chat_started import VideoChatStarted __all__ = [ "Birthday", + "BotVerification", "BusinessInfo", "BusinessMessage", "BusinessRecipients", diff --git a/pyrogram/types/user_and_chats/bot_verification.py b/pyrogram/types/user_and_chats/bot_verification.py new file mode 100644 index 00000000..40f90279 --- /dev/null +++ b/pyrogram/types/user_and_chats/bot_verification.py @@ -0,0 +1,63 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-present Dan +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from typing import Optional + +from pyrogram import raw, types +from ..object import Object + + +class BotVerification(Object): + """Information about bot verification. + + Parameters: + bot (:obj:`~pyrogram.types.User`): + Bot that is verified this user. + + custom_emoji_id (``int``): + Custom emoji icon identifier. + + description (``int``, *optional*): + Additional description about the verification. + """ + + def __init__( + self, + *, + bot: int, + custom_emoji_id: int, + description: str + ): + self.bot = bot + self.custom_emoji_id = custom_emoji_id + self.description = description + + @staticmethod + def _parse( + client, + verification: "raw.types.BotVerification", + users + ) -> Optional["BotVerification"]: + if not verification: + return None + + return BotVerification( + bot=types.User._parse(client, users.get(verification.bot_id)), + custom_emoji_id=verification.icon, + description=verification.description + ) diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index df97fca5..318a71c0 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -205,6 +205,12 @@ class Chat(Object): subscription_until_date (:py:obj:`~datetime.datetime`, *optional*): Channel members only. Date when the subscription expires. + + gifts_count (``int``, *optional*): + Number of gifts received by the user. + + bot_verification (:obj:`~pyrogram.types.BotVerification`, *optional*): + Information about bot verification. """ def __init__( @@ -258,7 +264,9 @@ class Chat(Object): birthday: "types.Birthday" = None, personal_chat: "types.Chat" = None, max_reaction_count: int = None, - subscription_until_date: datetime = None + subscription_until_date: datetime = None, + gifts_count: int = None, + bot_verification: "types.BotVerification" = None ): super().__init__(client) @@ -309,6 +317,8 @@ class Chat(Object): self.birthday = birthday self.personal_chat = personal_chat self.subscription_until_date = subscription_until_date + self.gifts_count = gifts_count + self.bot_verification = bot_verification @property def full_name(self) -> str: @@ -450,9 +460,10 @@ class Chat(Object): parsed_chat.bio = full_user.about parsed_chat.folder_id = getattr(full_user, "folder_id", None) parsed_chat.business_info = types.BusinessInfo._parse(client, full_user, users) - birthday = getattr(full_user, "birthday", None) - parsed_chat.birthday = types.Birthday._parse(birthday) if birthday is not None else None + parsed_chat.birthday = types.Birthday._parse(getattr(full_user, "birthday", None)) + parsed_chat.gifts_count = getattr(full_user, "stargifts_count", None) personal_chat_id = getattr(full_user, "personal_channel_id", None) + if personal_chat_id is not None: personal_chat = await client.invoke( raw.functions.channels.GetChannels( @@ -548,6 +559,7 @@ class Chat(Object): full_chat.available_reactions ) parsed_chat.max_reaction_count = getattr(full_chat, "reactions_limit", 11) + parsed_chat.bot_verification = types.BotVerification._parse(client, getattr(full_chat, "bot_verification", None), users) return parsed_chat