PyroFork: Add GetStickerSet methods and StickerSet types

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-04-10 19:35:05 +07:00
parent 2cd117f301
commit 9966bd92a5
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
6 changed files with 184 additions and 1 deletions

View file

@ -73,6 +73,19 @@ Chats
{chats}
Stickers
-----
.. autosummary::
:nosignatures:
{stickers}
.. toctree::
:hidden:
{stickers}
Users
-----

View file

@ -25,6 +25,7 @@ from .decorators import Decorators
from .invite_links import InviteLinks
from .messages import Messages
from .password import Password
from .stickers import Stickers
from .users import Users
from .utilities import Utilities
@ -36,6 +37,7 @@ class Methods(
Contacts,
Password,
Chats,
Stickers,
Users,
Messages,
Decorators,

View file

@ -0,0 +1,24 @@
# 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 .get_sticker_set import GetStickerSet
class Stickers(
GetStickerSet,
):
pass

View file

@ -0,0 +1,54 @@
# 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 GetStickerSet:
async def get_sticker_set(
self: "pyrogram.Client",
set_short_name: str
) -> "types.StickerSet":
"""Get info about a stickerset.
.. include:: /_includes/usable-by/users-bot.rst
Parameters:
set_short_name (``str``):
Stickerset shortname.
Returns:
:obj:`~pyrogram.types.StickerSet`: On success, the StickerSet information is returned.
Example:
.. code-block:: python
await app.get_sticker_set("mypack1")
"""
r = await self.invoke(
raw.functions.messages.GetStickerSet(
stickerset=raw.types.InputStickerSetShortName(short_name=set_short_name),
hash=0
)
)
return types.StickerSet._parse(r.set)

View file

@ -30,6 +30,7 @@ from .poll import Poll
from .poll_option import PollOption
from .reaction import Reaction
from .sticker import Sticker
from .stickerset import StickerSet
from .stripped_thumbnail import StrippedThumbnail
from .thumbnail import Thumbnail
from .venue import Venue
@ -42,6 +43,6 @@ from .message_reactions import MessageReactions
__all__ = [
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
"Reaction", "WebAppData", "MessageReactions"
]

View file

@ -0,0 +1,89 @@
# 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, Optional, Union
import pyrogram
from pyrogram import raw
from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType, ThumbnailSource
from ..object import Object
class StickerSet(Object):
"""One size of a photo or a file/sticker thumbnail.
Parameters:
id (``Integer``):
Identifier for this stickerset.
title (``String``):
Title of stickerset.
short_name (``String``):
Short name of stickerset, used when sharing stickerset using stickerset deep links.
count (``Integer``):
Number of stickers in stickerset.
masks (``Boolean``):
Is this a mask stickerset.
animated (``Boolean``):
Is this a animated stickerset.
videos (``Boolean``):
Is this a videos stickerset.
emojis (``Boolean``):
Is this a emojis stickerset.
"""
def __init__(
self,
*,
id: int,
title: str,
short_name: str,
count: int,
masks: bool = None,
animated: bool = None,
videos: bool = None,
emojis: bool = None
):
self.id = id
self.title = title
self.short_name = short_name
self.count = count
self.masks = masks
self.animated = animated
self.videos = videos
self.emojis = emojis
@staticmethod
def _parse(stickerset: "raw.types.StickerSet") -> "StickerSet":
return StickerSet(
id=getattr(stickerset,"id", None),
title=getattr(stickerset,"title", None),
short_name=getattr(stickerset,"short_name", None),
count=getattr(stickerset,"count", None),
masks=getattr(stickerset,"masks", None),
animated=getattr(stickerset,"animated", None),
videos=getattr(stickerset,"videos", None),
emojis=getattr(stickerset,"emojis", None)
)