Skip to content

Commit

Permalink
Add get_forum_topic_icon_stickers friendly method
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Mar 30, 2024
1 parent 3afa71f commit be37790
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ it can take advantage of new goodies!
+------------------------+

- Add ``message_thread_id`` parameter to :meth:`~pyrogram.Client.unpin_all_chat_messages`.
- Add :meth:`~pyrogram.Client.create_forum_topic`, :meth:`~pyrogram.Client.edit_forum_topic`, :meth:`~pyrogram.Client.close_forum_topic`, :meth:`~pyrogram.Client.reopen_forum_topic`, :meth:`~pyrogram.Client.hide_forum_topic`, :meth:`~pyrogram.Client.unhide_forum_topic`, :meth:`~pyrogram.Client.delete_forum_topic`.
- Add :meth:`~pyrogram.Client.create_forum_topic`, :meth:`~pyrogram.Client.edit_forum_topic`, :meth:`~pyrogram.Client.close_forum_topic`, :meth:`~pyrogram.Client.reopen_forum_topic`, :meth:`~pyrogram.Client.hide_forum_topic`, :meth:`~pyrogram.Client.unhide_forum_topic`, :meth:`~pyrogram.Client.delete_forum_topic`, :meth:`~pyrogram.Client.get_forum_topic_icon_stickers`.
- Add ``AioSQLiteStorage``, by stealing the following commits:
- `fded06e <https://github.com/KurimuzonAkuma/pyrogram/commit/fded06e7bdf8bb591fb5857d0f126986ccf357c8>`_

Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chat_topics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# 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_forum_topic_icon_stickers import GetForumTopicIconStickers
from .create_forum_topic import CreateForumTopic
from .edit_forum_topic import EditForumTopic
from .close_forum_topic import CloseForumTopic
Expand All @@ -26,6 +27,7 @@


class ChatTopics(
GetForumTopicIconStickers,
CreateForumTopic,
EditForumTopic,
CloseForumTopic,
Expand Down
50 changes: 50 additions & 0 deletions pyrogram/methods/chat_topics/get_forum_topic_icon_stickers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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

import pyrogram
from pyrogram import raw
from pyrogram import types


class GetForumTopicIconStickers:
async def get_forum_topic_icon_stickers(
self: "pyrogram.Client"
) -> List["types.Sticker"]:
"""Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
.. include:: /_includes/usable-by/users-bots.rst
Returns:
List of :obj:`~pyrogram.types.Sticker`: On success, a list of sticker objects is returned.
"""
result = await self.invoke(
raw.functions.messages.GetStickerSet(
stickerset=raw.types.InputStickerSetEmojiDefaultTopicIcons(),
hash=0
)
)

stickers = []
for item in result.documents:
attributes = {type(i): i for i in item.attributes}
sticker = await types.Sticker._parse(self, item, attributes)
stickers.append(sticker)

return pyrogram.types.List(stickers)

0 comments on commit be37790

Please sign in to comment.