mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Pyrofork: Add export_story_link method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
91f702fbda
commit
51821fb71e
5 changed files with 115 additions and 1 deletions
|
|
@ -271,6 +271,7 @@ def pyrogram_api():
|
|||
Stories
|
||||
delete_story
|
||||
edit_story
|
||||
export_story_link
|
||||
get_stories
|
||||
send_story
|
||||
""",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from .block_user import BlockUser
|
|||
from .delete_profile_photos import DeleteProfilePhotos
|
||||
from .delete_stories import DeleteStories
|
||||
from .edit_story import EditStory
|
||||
from .export_story_link import ExportStoryLink
|
||||
from .get_chat_photos import GetChatPhotos
|
||||
from .get_chat_photos_count import GetChatPhotosCount
|
||||
from .get_common_chats import GetCommonChats
|
||||
|
|
@ -39,6 +40,7 @@ class Users(
|
|||
BlockUser,
|
||||
DeleteStories,
|
||||
EditStory,
|
||||
ExportStoryLink,
|
||||
GetCommonChats,
|
||||
GetChatPhotos,
|
||||
SetProfilePhoto,
|
||||
|
|
|
|||
66
pyrogram/methods/users/export_story_link.py
Normal file
66
pyrogram/methods/users/export_story_link.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# 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
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class ExportStoryLink:
|
||||
async def export_story_link(
|
||||
self: "pyrogram.Client",
|
||||
user_id: Union[int, str],
|
||||
story_id: int,
|
||||
) -> types.ExportedStoryLink:
|
||||
"""Get one story link from an user by using story identifiers.
|
||||
|
||||
.. include:: /_includes/usable-by/users.rst
|
||||
|
||||
Parameters:
|
||||
user_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target user.
|
||||
For your personal story you can simply use "me" or "self".
|
||||
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||
|
||||
story_id (``int``):
|
||||
Pass a single story identifier of story (as integers).
|
||||
|
||||
Returns:
|
||||
:obj:`~pyrogram.types.ExportedStoryLink`: a single story link is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
# Get story link
|
||||
await app.export_story_link(user_id, 12345)
|
||||
|
||||
Raises:
|
||||
ValueError: In case of invalid arguments.
|
||||
"""
|
||||
|
||||
peer = await self.resolve_peer(user_id)
|
||||
|
||||
rpc = raw.functions.stories.ExportStoryLink(user_id=peer, story_id=story_id)
|
||||
|
||||
r = await self.invoke(rpc, sleep_threshold=-1)
|
||||
|
||||
return types.ExportedStoryLink._parse(r)
|
||||
|
|
@ -43,9 +43,10 @@ from .web_page import WebPage
|
|||
from .message_reactions import MessageReactions
|
||||
from .story import Story
|
||||
from .story_views import StoryViews
|
||||
from .exported_story_link import ExportedStoryLink
|
||||
|
||||
__all__ = [
|
||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
||||
"Reaction", "WebAppData", "MessageReactions", "Story", "StoryViews", "StoriesPrivacy"
|
||||
"Reaction", "WebAppData", "MessageReactions", "Story", "StoryViews", "StoriesPrivacy", "ExportedStoryLink"
|
||||
]
|
||||
|
|
|
|||
44
pyrogram/types/messages_and_media/exported_story_link.py
Normal file
44
pyrogram/types/messages_and_media/exported_story_link.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# 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/>.
|
||||
|
||||
from pyrogram import raw
|
||||
from typing import List
|
||||
from ..object import Object
|
||||
|
||||
class ExportedStoryLink(Object):
|
||||
"""Contains information about a story viewers.
|
||||
|
||||
|
||||
Parameters:
|
||||
link (``str``):
|
||||
The link of the story.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, *,
|
||||
link: str
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.link = link
|
||||
|
||||
@staticmethod
|
||||
def _parse(exportedstorylink: "raw.types.ExportedStoryLink") -> "ExportedStoryLink":
|
||||
return ExportedStoryLink(
|
||||
link=getattr(exportedstorylink,"link", None)
|
||||
)
|
||||
Loading…
Reference in a new issue