diff --git a/pyrogram/methods/premium/__init__.py b/pyrogram/methods/premium/__init__.py index 016929c4..29699583 100644 --- a/pyrogram/methods/premium/__init__.py +++ b/pyrogram/methods/premium/__init__.py @@ -17,10 +17,12 @@ # along with Pyrogram. If not, see . from .apply_boost import ApplyBoost +from .get_boosts_status import GetBoostsStatus from .get_boosts import GetBoosts class Premium( ApplyBoost, + GetBoostsStatus, GetBoosts ): pass diff --git a/pyrogram/methods/premium/get_boosts_status.py b/pyrogram/methods/premium/get_boosts_status.py new file mode 100644 index 00000000..8f56c75a --- /dev/null +++ b/pyrogram/methods/premium/get_boosts_status.py @@ -0,0 +1,52 @@ +# 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 Union + +import pyrogram +from pyrogram import raw +from pyrogram import types + + +class GetBoostsStatus: + async def get_boosts_status( + self: "pyrogram.Client", + chat_id: Union[int, str] + ) -> bool: + """Get boosts status of channel + + .. include:: /_includes/usable-by/users-bots.rst + + Parameters: + chat_id (``int`` | ``str``): + Unique identifier (int) or username (str) of the target chat. + + Returns: + :obj:`~pyrogram.types.BoostsStatus`: On success. + + Example: + .. code-block:: python + + # get boosts list + app.get_boosts() + """ + r = await self.invoke( + raw.functions.premium.GetBoostsStatus(peer=await self.resolve_peer(chat_id)) + ) + + return types.BoostsStatus._parse(r) diff --git a/pyrogram/types/messages_and_media/__init__.py b/pyrogram/types/messages_and_media/__init__.py index edb9754c..cc853e23 100644 --- a/pyrogram/types/messages_and_media/__init__.py +++ b/pyrogram/types/messages_and_media/__init__.py @@ -18,6 +18,7 @@ from .animation import Animation from .audio import Audio +from .boosts_status import BoostsStatus from .contact import Contact from .dice import Dice from .document import Document @@ -55,7 +56,7 @@ from .message_story import MessageStory from .my_boost import MyBoost __all__ = [ - "Animation", "Audio", "Contact", "Document", "ForumTopic", "ForumTopicCreated", + "Animation", "Audio", "BoostsStatus", "Contact", "Document", "ForumTopic", "ForumTopicCreated", "ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", "GeneralTopicHidden", "GeneralTopicUnhidden", "Game", "Giveaway", "Location", "Message", "MessageEntity", "Photo", "Thumbnail", "StrippedThumbnail", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "Poll", "PollOption", "Sticker", diff --git a/pyrogram/types/messages_and_media/boosts_status.py b/pyrogram/types/messages_and_media/boosts_status.py new file mode 100644 index 00000000..f2e6ac43 --- /dev/null +++ b/pyrogram/types/messages_and_media/boosts_status.py @@ -0,0 +1,88 @@ +# 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 List + +from pyrogram import raw, types +from ..object import Object + + +class BoostsStatus(Object): + """Contains information about boost. + + Parameters: + level (``int``): + Level of channel. + + current_level_boosts (``int``): + Number of boosts required for the current level. + + boosts (``int``): + Total number of boosts. + + boost_url (``str``): + Link that can be used to give a boost to a channel. + + my_boost (``bool``, *optional*): + True, if you boost this channel. + + gift_boosts (``int``, *optional*): + N/A + + next_level_boosts (``int``, *optional*): + Number of boosts at which the next level will be reached. + + my_boost_slots (List of ``int``, *optional*): + Boost slots that are given to the channel. + """ + + def __init__( + self, + *, + level: int, + current_level_boosts: int, + boosts: int, + boost_url: str, + my_boost: bool = None, + gift_boosts: int = None, + next_level_boosts: int = None, + my_boost_slots: List[int] = None + ): + super().__init__() + + self.level = level + self.current_level_boosts = current_level_boosts + self.boosts = boosts + self.boost_url = boost_url + self.my_boost = my_boost + self.gift_boosts = gift_boosts + self.next_level_boosts = next_level_boosts + self.my_boost_slots = my_boost_slots + + @staticmethod + def _parse(boosts_status: "raw.types.premium.BoostsStatus") -> "BoostsStatus": + return BoostsStatus( + level=boosts_status.level, + current_level_boosts=boosts_status.current_level_boosts, + boosts=boosts_status.boosts, + boost_url=boosts_status.boost_url, + my_boost=getattr(boosts_status, "my_boost", None), + gift_boosts=getattr(boosts_status, "gift_boosts", None), + next_level_boosts=getattr(boosts_status, "next_level_boosts", None), + my_boost_slots=types.List(boosts_status.my_boost_slots) or None, + ) diff --git a/pyrogram/types/messages_and_media/my_boost.py b/pyrogram/types/messages_and_media/my_boost.py index 26a03a25..ed634f01 100644 --- a/pyrogram/types/messages_and_media/my_boost.py +++ b/pyrogram/types/messages_and_media/my_boost.py @@ -28,7 +28,7 @@ class MyBoost(Object): Parameters: slot (``int``): - Unique user identifier of story sender. + Boost slot. date (:py:obj:`~datetime.datetime`): Date the boost was sent.