Skip to content

Commit

Permalink
Pyrofork: Add forward bound method to Story
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <[email protected]>
  • Loading branch information
wulan17 committed Dec 6, 2023
1 parent bff0c6b commit 14f599e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ def get_title_list(s: str) -> list:
Story.edit_privacy
Story.edit_video
Story.export_link
Story.forward
Story.reply_text
Story.reply_animation
Story.reply_audio
Expand Down
85 changes: 85 additions & 0 deletions pyrogram/types/messages_and_media/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1715,3 +1715,88 @@ async def export_link(self) -> "types.ExportedStoryLink":
RPCError: In case of a Telegram RPC error.
"""
return await self._client.export_story_link(from_id=self.from_user.id if self.from_user else self.sender_chat.id, story_id=self.id)

async def forward(
self,
channel_id: int = None,
privacy: "enums.StoriesPrivacyRules" = None,
allowed_users: List[int] = None,
denied_users: List[int] = None,
#allowed_chats: List[int] = None,
#denied_chats: List[int] = None,
pinned: bool = None,
protect_content: bool = None,
caption: str = None,
parse_mode: "enums.ParseMode" = None,
caption_entities: List["types.MessageEntity"] = None,
period: int = None
):
"""Bound method *forward* of :obj:`~pyrogram.types.Message`.
Use as a shortcut for:
.. code-block:: python
await client.forward_story(
from_chat_id='wulan17',
from_story_id=1,
caption='Hello guys.'
)
Parameters:
channel_id (``int``, *optional*):
Unique identifier (int) of the target channel.
If you want to forward story to a channel.
privacy (:obj:`~pyrogram.enums.StoriesPrivacyRules`, *optional*):
Story privacy.
Defaults to :obj:`~pyrogram.enums.StoriesPrivacyRules.PUBLIC`
allowed_users (List of ``int``, *optional*):
List of user_id whos allowed to view the story.
denied_users (List of ``int``, *optional*):
List of user_id whos denied to view the story.
pinned (``bool``, *optional*):
if True, the story will be pinned.
default to False.
protect_content (``bool``, *optional*):
Protects the contents of the sent story from forwarding and saving.
default to False.
caption (``str``, *optional*):
Story caption, 0-1024 characters.
parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
By default, texts are parsed using both Markdown and HTML styles.
You can combine both syntaxes together.
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in the caption, which can be specified instead of *parse_mode*.
period (``int``, *optional*):
How long the story will posted, in secs.
only for premium users.
Returns:
:obj:`~pyrogram.types.Story` a single story is returned.
Raises:
ValueError: In case of invalid arguments.
"""
return await self._client.send_story(
channel_id=channel_id,
privacy=privacy,
allowed_users=allowed_users,
denied_users=denied_users,
pinned=pinned,
protect_content=protect_content,
caption=caption,
caption_entities=caption_entities,
parse_mode=parse_mode,
period=period,
forward_from_chat_id=self.from_user.id if self.from_user is not None else self.sender_chat.id,
forward_from_story_id=self.id
)

0 comments on commit 14f599e

Please sign in to comment.