Add hide_stories method

This commit is contained in:
KurimuzonAkuma 2023-10-13 22:29:09 +03:00
parent db54c77cf3
commit 3c57bda622
2 changed files with 62 additions and 3 deletions

View File

@ -22,12 +22,13 @@ from .edit_story import EditStory
from .export_story_link import ExportStoryLink from .export_story_link import ExportStoryLink
from .get_all_stories import GetAllStories from .get_all_stories import GetAllStories
from .get_peer_stories import GetPeerStories from .get_peer_stories import GetPeerStories
from .get_stories_archive import GetStoriesArchive
from .get_stories import GetStories from .get_stories import GetStories
from .get_stories_archive import GetStoriesArchive
from .hide_stories import HideStories
from .increment_story_views import IncrementStoryViews from .increment_story_views import IncrementStoryViews
from .pin_stories import PinStories
from .read_stories import ReadStories from .read_stories import ReadStories
from .send_story import SendStory from .send_story import SendStory
from .toggle_stories_pinned import ToggleStoriesPinned
class Stories( class Stories(
ApplyBoost, ApplyBoost,
@ -38,9 +39,10 @@ class Stories(
GetPeerStories, GetPeerStories,
GetStories, GetStories,
GetStoriesArchive, GetStoriesArchive,
HideStories,
IncrementStoryViews, IncrementStoryViews,
PinStories,
ReadStories, ReadStories,
SendStory, SendStory,
ToggleStoriesPinned
): ):
pass pass

View File

@ -0,0 +1,57 @@
# 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
class HideStories:
async def hide_stories(
self: "pyrogram.Client",
chat_id: Union[int, str],
hidden: bool = None
) -> bool:
"""Toggle peer stories hidden
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
Returns:
``str``: On success, a bool is returned.
Example:
.. code-block:: python
# Export a story link
link = app.hide_stories("me")
"""
r = await self.invoke(
raw.functions.stories.TogglePeerStoriesHidden(
peer=await self.resolve_peer(chat_id),
hidden=hidden
)
)
return r