Pyrofork: Add delete_story method

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-17 18:38:09 +07:00
parent 7a815c0ed4
commit 91f702fbda
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
3 changed files with 68 additions and 0 deletions

View file

@ -269,6 +269,7 @@ def pyrogram_api():
""", """,
stories=""" stories="""
Stories Stories
delete_story
edit_story edit_story
get_stories get_stories
send_story send_story

View file

@ -18,6 +18,7 @@
from .block_user import BlockUser from .block_user import BlockUser
from .delete_profile_photos import DeleteProfilePhotos from .delete_profile_photos import DeleteProfilePhotos
from .delete_stories import DeleteStories
from .edit_story import EditStory from .edit_story import EditStory
from .get_chat_photos import GetChatPhotos from .get_chat_photos import GetChatPhotos
from .get_chat_photos_count import GetChatPhotosCount from .get_chat_photos_count import GetChatPhotosCount
@ -36,6 +37,7 @@ from .update_profile import UpdateProfile
class Users( class Users(
BlockUser, BlockUser,
DeleteStories,
EditStory, EditStory,
GetCommonChats, GetCommonChats,
GetChatPhotos, GetChatPhotos,

View file

@ -0,0 +1,65 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
import logging
from typing import Union, List, Iterable
import pyrogram
from pyrogram import raw
from pyrogram import types
log = logging.getLogger(__name__)
class DeleteStories:
async def delete_stories(
self: "pyrogram.Client",
story_ids: Union[int, Iterable[int]],
) -> bool:
"""Delete one or more story by using story identifiers.
.. include:: /_includes/usable-by/users.rst
Parameters:
story_ids (``int`` | Iterable of ``int``):
Pass a single story identifier or an iterable of story ids (as integers) to get the content of the
story themselves.
Returns:
`bool`: On success, a True is returned.
Example:
.. code-block:: python
# Delete one story
await app.delete_stories(12345)
# Delete more than one story (list of stories)
await app.delete_stories([12345, 12346])
"""
is_iterable = not isinstance(story_ids, int)
ids = list(story_ids) if is_iterable else [story_ids]
try:
await self.invoke(
raw.functions.stories.DeleteStories(id=ids)
)
except Exception as e:
print(e)
return False
return True