mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-30 17:43:32 +00:00
Add get_boosts_status method
This commit is contained in:
parent
a56a037688
commit
34a9b06fbb
@ -17,10 +17,12 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .apply_boost import ApplyBoost
|
from .apply_boost import ApplyBoost
|
||||||
|
from .get_boosts_status import GetBoostsStatus
|
||||||
from .get_boosts import GetBoosts
|
from .get_boosts import GetBoosts
|
||||||
|
|
||||||
class Premium(
|
class Premium(
|
||||||
ApplyBoost,
|
ApplyBoost,
|
||||||
|
GetBoostsStatus,
|
||||||
GetBoosts
|
GetBoosts
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
52
pyrogram/methods/premium/get_boosts_status.py
Normal file
52
pyrogram/methods/premium/get_boosts_status.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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)
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from .animation import Animation
|
from .animation import Animation
|
||||||
from .audio import Audio
|
from .audio import Audio
|
||||||
|
from .boosts_status import BoostsStatus
|
||||||
from .contact import Contact
|
from .contact import Contact
|
||||||
from .dice import Dice
|
from .dice import Dice
|
||||||
from .document import Document
|
from .document import Document
|
||||||
@ -55,7 +56,7 @@ from .message_story import MessageStory
|
|||||||
from .my_boost import MyBoost
|
from .my_boost import MyBoost
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Animation", "Audio", "Contact", "Document", "ForumTopic", "ForumTopicCreated",
|
"Animation", "Audio", "BoostsStatus", "Contact", "Document", "ForumTopic", "ForumTopicCreated",
|
||||||
"ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", "GeneralTopicHidden",
|
"ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", "GeneralTopicHidden",
|
||||||
"GeneralTopicUnhidden", "Game", "Giveaway", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
"GeneralTopicUnhidden", "Game", "Giveaway", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||||
"StrippedThumbnail", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "Poll", "PollOption", "Sticker",
|
"StrippedThumbnail", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "Poll", "PollOption", "Sticker",
|
||||||
|
88
pyrogram/types/messages_and_media/boosts_status.py
Normal file
88
pyrogram/types/messages_and_media/boosts_status.py
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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,
|
||||||
|
)
|
@ -28,7 +28,7 @@ class MyBoost(Object):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
slot (``int``):
|
slot (``int``):
|
||||||
Unique user identifier of story sender.
|
Boost slot.
|
||||||
|
|
||||||
date (:py:obj:`~datetime.datetime`):
|
date (:py:obj:`~datetime.datetime`):
|
||||||
Date the boost was sent.
|
Date the boost was sent.
|
||||||
|
Loading…
Reference in New Issue
Block a user