mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-09 00:14:50 +00:00
Pyrofork: Add Story Support
Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add Story and StoryViews Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add get_stories method Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add StoriesPrivacy Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add send_story method Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add edit_story method Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add delete_story method Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add export_story_link method Signed-off-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Add story bound method Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
4cf50e6e04
commit
b670101dac
33 changed files with 2766 additions and 6 deletions
|
|
@ -268,6 +268,14 @@ def pyrogram_api():
|
||||||
get_default_emoji_statuses
|
get_default_emoji_statuses
|
||||||
set_emoji_status
|
set_emoji_status
|
||||||
""",
|
""",
|
||||||
|
stories="""
|
||||||
|
Stories
|
||||||
|
delete_stories
|
||||||
|
edit_story
|
||||||
|
export_story_link
|
||||||
|
get_stories
|
||||||
|
send_story
|
||||||
|
""",
|
||||||
stickers="""
|
stickers="""
|
||||||
Stickers
|
Stickers
|
||||||
add_sticker_to_set
|
add_sticker_to_set
|
||||||
|
|
@ -450,6 +458,12 @@ def pyrogram_api():
|
||||||
GeneralTopicHidden
|
GeneralTopicHidden
|
||||||
GeneralTopicUnhidden
|
GeneralTopicUnhidden
|
||||||
""",
|
""",
|
||||||
|
stories="""
|
||||||
|
Stories
|
||||||
|
Story
|
||||||
|
StoriesPrivacy
|
||||||
|
StoryViews
|
||||||
|
""",
|
||||||
bot_keyboards="""
|
bot_keyboards="""
|
||||||
Bot keyboards
|
Bot keyboards
|
||||||
ReplyKeyboardMarkup
|
ReplyKeyboardMarkup
|
||||||
|
|
@ -521,6 +535,7 @@ def pyrogram_api():
|
||||||
InputMessageContent
|
InputMessageContent
|
||||||
InputMessageContent
|
InputMessageContent
|
||||||
InputReplyToMessage
|
InputReplyToMessage
|
||||||
|
InputReplyToStory
|
||||||
InputTextMessageContent
|
InputTextMessageContent
|
||||||
""",
|
""",
|
||||||
authorization="""
|
authorization="""
|
||||||
|
|
@ -622,6 +637,27 @@ def pyrogram_api():
|
||||||
User.block
|
User.block
|
||||||
User.unblock
|
User.unblock
|
||||||
""",
|
""",
|
||||||
|
story="""
|
||||||
|
Story
|
||||||
|
Story.delete
|
||||||
|
Story.edit
|
||||||
|
Story.edit_animation
|
||||||
|
Story.edit_caption
|
||||||
|
Story.edit_photo
|
||||||
|
Story.edit_privacy
|
||||||
|
Story.edit_video
|
||||||
|
Story.export_link
|
||||||
|
Story.reply_text
|
||||||
|
Story.reply_animation
|
||||||
|
Story.reply_audio
|
||||||
|
Story.reply_cached_media
|
||||||
|
Story.reply_media_group
|
||||||
|
Story.reply_photo
|
||||||
|
Story.reply_sticker
|
||||||
|
Story.reply_video
|
||||||
|
Story.reply_video_note
|
||||||
|
Story.reply_voice
|
||||||
|
""",
|
||||||
callback_query="""
|
callback_query="""
|
||||||
Callback Query
|
Callback Query
|
||||||
CallbackQuery.answer
|
CallbackQuery.answer
|
||||||
|
|
|
||||||
13
compiler/docs/template/bound-methods.rst
vendored
13
compiler/docs/template/bound-methods.rst
vendored
|
|
@ -36,6 +36,19 @@ Message
|
||||||
|
|
||||||
{message_toctree}
|
{message_toctree}
|
||||||
|
|
||||||
|
Story
|
||||||
|
-----
|
||||||
|
|
||||||
|
.. hlist::
|
||||||
|
:columns: 3
|
||||||
|
|
||||||
|
{story_hlist}
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:hidden:
|
||||||
|
|
||||||
|
{story_toctree}
|
||||||
|
|
||||||
Chat
|
Chat
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
||||||
13
compiler/docs/template/methods.rst
vendored
13
compiler/docs/template/methods.rst
vendored
|
|
@ -60,6 +60,19 @@ Messages
|
||||||
|
|
||||||
{messages}
|
{messages}
|
||||||
|
|
||||||
|
Stories
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:nosignatures:
|
||||||
|
|
||||||
|
{stories}
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:hidden:
|
||||||
|
|
||||||
|
{stories}
|
||||||
|
|
||||||
Chats
|
Chats
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
||||||
13
compiler/docs/template/types.rst
vendored
13
compiler/docs/template/types.rst
vendored
|
|
@ -47,6 +47,19 @@ Messages & Media
|
||||||
|
|
||||||
{messages_media}
|
{messages_media}
|
||||||
|
|
||||||
|
Stories
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:nosignatures:
|
||||||
|
|
||||||
|
{stories}
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:hidden:
|
||||||
|
|
||||||
|
{stories}
|
||||||
|
|
||||||
Bot keyboards
|
Bot keyboards
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
8
docs/source/api/enums/StoriesPrivacy.rst
Normal file
8
docs/source/api/enums/StoriesPrivacy.rst
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
StoriesPrivacy
|
||||||
|
==============
|
||||||
|
|
||||||
|
.. autoclass:: pyrogram.enums.StoriesPrivacy()
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
:file: ./cleanup.html
|
||||||
|
|
@ -27,6 +27,7 @@ to apply only a valid value among the expected ones.
|
||||||
SentCodeType
|
SentCodeType
|
||||||
NextCodeType
|
NextCodeType
|
||||||
UserStatus
|
UserStatus
|
||||||
|
StoriesPrivacy
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:hidden:
|
:hidden:
|
||||||
|
|
@ -44,4 +45,5 @@ to apply only a valid value among the expected ones.
|
||||||
PollType
|
PollType
|
||||||
SentCodeType
|
SentCodeType
|
||||||
NextCodeType
|
NextCodeType
|
||||||
UserStatus
|
UserStatus
|
||||||
|
StoriesPrivacy
|
||||||
|
|
@ -29,6 +29,7 @@ from .next_code_type import NextCodeType
|
||||||
from .parse_mode import ParseMode
|
from .parse_mode import ParseMode
|
||||||
from .poll_type import PollType
|
from .poll_type import PollType
|
||||||
from .sent_code_type import SentCodeType
|
from .sent_code_type import SentCodeType
|
||||||
|
from .stories_privacy import StoriesPrivacy
|
||||||
from .user_status import UserStatus
|
from .user_status import UserStatus
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
@ -44,6 +45,7 @@ __all__ = [
|
||||||
'NextCodeType',
|
'NextCodeType',
|
||||||
'ParseMode',
|
'ParseMode',
|
||||||
'PollType',
|
'PollType',
|
||||||
'SentCodeType',
|
'SentCodeType',
|
||||||
|
"StoriesPrivacy",
|
||||||
'UserStatus'
|
'UserStatus'
|
||||||
]
|
]
|
||||||
|
|
|
||||||
40
pyrogram/enums/stories_privacy.py
Normal file
40
pyrogram/enums/stories_privacy.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# 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 enum import auto
|
||||||
|
|
||||||
|
from .auto_name import AutoName
|
||||||
|
|
||||||
|
|
||||||
|
class StoriesPrivacy(AutoName):
|
||||||
|
"""Poll type enumeration used in :obj:`~pyrogram.types.Story`."""
|
||||||
|
|
||||||
|
PUBLIC = auto()
|
||||||
|
"Public stories"
|
||||||
|
|
||||||
|
CLOSE_FRIENDS = auto()
|
||||||
|
"Close_Friends stories"
|
||||||
|
|
||||||
|
CONTACTS = auto()
|
||||||
|
"Contacts only stories"
|
||||||
|
|
||||||
|
PRIVATE = auto()
|
||||||
|
"Private stories"
|
||||||
|
|
||||||
|
NO_CONTACTS = auto()
|
||||||
|
"Hide stories from contacts"
|
||||||
|
|
@ -49,6 +49,7 @@ class SendAnimation:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -123,6 +124,9 @@ class SendAnimation:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -184,6 +188,9 @@ class SendAnimation:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(animation, str):
|
if isinstance(animation, str):
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class SendAudio:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -116,6 +117,9 @@ class SendAudio:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -178,6 +182,9 @@ class SendAudio:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(audio, str):
|
if isinstance(audio, str):
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ class SendCachedMedia:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -88,6 +89,9 @@ class SendCachedMedia:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -111,6 +115,9 @@ class SendCachedMedia:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
media = utils.get_input_media_from_file_id(file_id)
|
media = utils.get_input_media_from_file_id(file_id)
|
||||||
media.spoiler = has_spoiler
|
media.spoiler = has_spoiler
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class SendDice:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -69,6 +70,9 @@ class SendDice:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -99,6 +103,9 @@ class SendDice:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
r = await self.invoke(
|
r = await self.invoke(
|
||||||
raw.functions.messages.SendMedia(
|
raw.functions.messages.SendMedia(
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ class SendDocument:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -108,6 +109,9 @@ class SendDocument:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -165,6 +169,9 @@ class SendDocument:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(document, str):
|
if isinstance(document, str):
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ class SendMediaGroup:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
) -> List["types.Message"]:
|
) -> List["types.Message"]:
|
||||||
|
|
@ -72,6 +73,9 @@ class SendMediaGroup:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -101,6 +105,9 @@ class SendMediaGroup:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
for i in media:
|
for i in media:
|
||||||
if isinstance(i, types.InputMediaPhoto):
|
if isinstance(i, types.InputMediaPhoto):
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class SendMessage:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -78,6 +79,9 @@ class SendMessage:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -132,6 +136,9 @@ class SendMessage:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
r = await self.invoke(
|
r = await self.invoke(
|
||||||
raw.functions.messages.SendMessage(
|
raw.functions.messages.SendMessage(
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class SendPhoto:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -99,6 +100,9 @@ class SendPhoto:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -156,6 +160,9 @@ class SendPhoto:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(photo, str):
|
if isinstance(photo, str):
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class SendSticker:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -77,6 +78,9 @@ class SendSticker:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -129,6 +133,9 @@ class SendSticker:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(sticker, str):
|
if isinstance(sticker, str):
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ class SendVideo:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -129,6 +130,9 @@ class SendVideo:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message.
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -189,6 +193,9 @@ class SendVideo:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(video, str):
|
if isinstance(video, str):
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ class SendVideoNote:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -90,7 +91,10 @@ class SendVideoNote:
|
||||||
for forum supergroups only.
|
for forum supergroups only.
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message
|
If the message is a reply, ID of the original message.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -143,6 +147,9 @@ class SendVideoNote:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(video_note, str):
|
if isinstance(video_note, str):
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ class SendVoice:
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
|
reply_to_story_id: int = None,
|
||||||
schedule_date: datetime = None,
|
schedule_date: datetime = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
reply_markup: Union[
|
reply_markup: Union[
|
||||||
|
|
@ -94,6 +95,12 @@ class SendVoice:
|
||||||
|
|
||||||
reply_to_message_id (``int``, *optional*):
|
reply_to_message_id (``int``, *optional*):
|
||||||
If the message is a reply, ID of the original message
|
If the message is a reply, ID of the original message
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
|
reply_to_story_id (``int``, *optional*):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
|
||||||
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
Date when the message will be automatically sent.
|
Date when the message will be automatically sent.
|
||||||
|
|
@ -148,6 +155,9 @@ class SendVoice:
|
||||||
reply_to = None
|
reply_to = None
|
||||||
if reply_to_message_id or message_thread_id:
|
if reply_to_message_id or message_thread_id:
|
||||||
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
|
||||||
|
if reply_to_story_id:
|
||||||
|
user_id = await self.resolve_peer(chat_id)
|
||||||
|
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(voice, str):
|
if isinstance(voice, str):
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,17 @@
|
||||||
|
|
||||||
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 .export_story_link import ExportStoryLink
|
||||||
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
|
||||||
from .get_common_chats import GetCommonChats
|
from .get_common_chats import GetCommonChats
|
||||||
from .get_default_emoji_statuses import GetDefaultEmojiStatuses
|
from .get_default_emoji_statuses import GetDefaultEmojiStatuses
|
||||||
from .get_me import GetMe
|
from .get_me import GetMe
|
||||||
|
from .get_stories import GetStories
|
||||||
from .get_users import GetUsers
|
from .get_users import GetUsers
|
||||||
|
from .send_story import SendStory
|
||||||
from .set_emoji_status import SetEmojiStatus
|
from .set_emoji_status import SetEmojiStatus
|
||||||
from .set_profile_photo import SetProfilePhoto
|
from .set_profile_photo import SetProfilePhoto
|
||||||
from .set_username import SetUsername
|
from .set_username import SetUsername
|
||||||
|
|
@ -33,17 +38,22 @@ from .update_profile import UpdateProfile
|
||||||
|
|
||||||
class Users(
|
class Users(
|
||||||
BlockUser,
|
BlockUser,
|
||||||
|
DeleteStories,
|
||||||
|
EditStory,
|
||||||
|
ExportStoryLink,
|
||||||
GetCommonChats,
|
GetCommonChats,
|
||||||
GetChatPhotos,
|
GetChatPhotos,
|
||||||
SetProfilePhoto,
|
SetProfilePhoto,
|
||||||
DeleteProfilePhotos,
|
DeleteProfilePhotos,
|
||||||
GetUsers,
|
GetUsers,
|
||||||
GetMe,
|
GetMe,
|
||||||
|
GetStories,
|
||||||
SetUsername,
|
SetUsername,
|
||||||
GetChatPhotosCount,
|
GetChatPhotosCount,
|
||||||
UnblockUser,
|
UnblockUser,
|
||||||
UpdateProfile,
|
UpdateProfile,
|
||||||
GetDefaultEmojiStatuses,
|
GetDefaultEmojiStatuses,
|
||||||
SetEmojiStatus
|
SetEmojiStatus,
|
||||||
|
SendStory
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
65
pyrogram/methods/users/delete_stories.py
Normal file
65
pyrogram/methods/users/delete_stories.py
Normal 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
|
||||||
240
pyrogram/methods/users/edit_story.py
Normal file
240
pyrogram/methods/users/edit_story.py
Normal file
|
|
@ -0,0 +1,240 @@
|
||||||
|
# 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 os
|
||||||
|
import re
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import enums, raw, types, utils
|
||||||
|
from pyrogram.file_id import FileType
|
||||||
|
|
||||||
|
class EditStory:
|
||||||
|
def _split(self, message, entities, *args, **kwargs):
|
||||||
|
return message, entities
|
||||||
|
|
||||||
|
async def edit_story(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
story_id: int,
|
||||||
|
privacy: "enums.StoriesPrivacy" = None,
|
||||||
|
allowed_users: List[int] = None,
|
||||||
|
denied_users: List[int] = None,
|
||||||
|
allowed_chats: List[int] = None,
|
||||||
|
denied_chats: List[int] = None,
|
||||||
|
animation: str = None,
|
||||||
|
photo: str = None,
|
||||||
|
video: str = None,
|
||||||
|
caption: str = None,
|
||||||
|
parse_mode: "enums.ParseMode" = None,
|
||||||
|
caption_entities: List["types.MessageEntity"] = None
|
||||||
|
) -> "types.Story":
|
||||||
|
"""Edit story.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
story_id (``int``):
|
||||||
|
Unique identifier (int) of the target story.
|
||||||
|
|
||||||
|
animation (``str`` | ``BinaryIO``, *optional*):
|
||||||
|
New story Animation.
|
||||||
|
Pass a file_id as string to send a animation that exists on the Telegram servers,
|
||||||
|
pass an HTTP URL as a string for Telegram to get a animation from the Internet,
|
||||||
|
pass a file path as string to upload a new animation that exists on your local machine, or
|
||||||
|
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
|
||||||
|
|
||||||
|
photo (``str`` | ``BinaryIO``, *optional*):
|
||||||
|
New story photo.
|
||||||
|
Pass a file_id as string to send a photo that exists on the Telegram servers,
|
||||||
|
pass an HTTP URL as a string for Telegram to get a photo from the Internet,
|
||||||
|
pass a file path as string to upload a new photo that exists on your local machine, or
|
||||||
|
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
|
||||||
|
|
||||||
|
video (``str`` | ``BinaryIO``, *optional*):
|
||||||
|
New story video.
|
||||||
|
Pass a file_id as string to send a video that exists on the Telegram servers,
|
||||||
|
pass an HTTP URL as a string for Telegram to get a video from the Internet,
|
||||||
|
pass a file path as string to upload a new video that exists on your local machine, or
|
||||||
|
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
|
||||||
|
|
||||||
|
privacy (:obj:`~pyrogram.enums.StoriesPrivacy`, *optional*):
|
||||||
|
Story privacy.
|
||||||
|
|
||||||
|
allowed_chats (List of ``int``, *optional*):
|
||||||
|
List of chat_id which participant allowed to view the story.
|
||||||
|
|
||||||
|
denied_chats (List of ``int``, *optional*):
|
||||||
|
List of chat_id which participant denied to view the story.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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*.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.Story` a single story is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Edit story photo
|
||||||
|
photo_id = "abcd12345"
|
||||||
|
await app.edit_story(story_id=1, photo=photo_id)
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: In case of invalid arguments.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# TODO: MediaArea
|
||||||
|
|
||||||
|
media = None
|
||||||
|
|
||||||
|
if privacy:
|
||||||
|
privacy_rules = [types.StoriesPrivacy(type=privacy)]
|
||||||
|
|
||||||
|
if animation:
|
||||||
|
if isinstance(animation, str):
|
||||||
|
if os.path.isfile(animation):
|
||||||
|
file = await self.save_file(animation)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(animation) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
),
|
||||||
|
raw.types.DocumentAttributeAnimated()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif re.match("^https?://", animation):
|
||||||
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
|
url=animation
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
media = utils.get_input_media_from_file_id(animation, FileType.ANIMATION)
|
||||||
|
else:
|
||||||
|
file = await self.save_file(animation)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(animation) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
),
|
||||||
|
raw.types.DocumentAttributeAnimated()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif photo:
|
||||||
|
if isinstance(photo, str):
|
||||||
|
if os.path.isfile(photo):
|
||||||
|
file = await self.save_file(photo)
|
||||||
|
media = raw.types.InputMediaUploadedPhoto(
|
||||||
|
file=file
|
||||||
|
)
|
||||||
|
elif re.match("^https?://", photo):
|
||||||
|
media = raw.types.InputMediaPhotoExternal(
|
||||||
|
url=photo
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO)
|
||||||
|
else:
|
||||||
|
file = await self.save_file(photo)
|
||||||
|
media = raw.types.InputMediaUploadedPhoto(
|
||||||
|
file=file
|
||||||
|
)
|
||||||
|
elif video:
|
||||||
|
if isinstance(video, str):
|
||||||
|
if os.path.isfile(video):
|
||||||
|
file = await self.save_file(video)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(video) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif re.match("^https?://", video):
|
||||||
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
|
url=video
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
media = utils.get_input_media_from_file_id(video, FileType.VIDEO)
|
||||||
|
else:
|
||||||
|
file = await self.save_file(video)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(video) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
text = None
|
||||||
|
entities = None
|
||||||
|
if caption:
|
||||||
|
text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities))
|
||||||
|
|
||||||
|
if allowed_chats and len(allowed_chats) > 0:
|
||||||
|
chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||||
|
if denied_chats and len(denied_chats) > 0:
|
||||||
|
chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||||
|
if allowed_users and len(allowed_users) > 0:
|
||||||
|
users = [await self.resolve_peer(user_id) for user_id in allowed_users]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users))
|
||||||
|
if denied_users and len(denied_users) > 0:
|
||||||
|
users = [await self.resolve_peer(user_id) for user_id in denied_users]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueDisallowUsers(users=users))
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.stories.EditStory(
|
||||||
|
id=story_id,
|
||||||
|
media=media,
|
||||||
|
privacy_rules=privacy_rules,
|
||||||
|
caption=text,
|
||||||
|
entities=entities
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return await types.Story._parse(self, r.updates[0].story, r.updates[0].user_id)
|
||||||
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)
|
||||||
76
pyrogram/methods/users/get_stories.py
Normal file
76
pyrogram/methods/users/get_stories.py
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
# 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 GetStories:
|
||||||
|
async def get_stories(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
user_id: Union[int, str],
|
||||||
|
story_ids: Union[int, Iterable[int]],
|
||||||
|
) -> Union["types.Story", List["types.Story"]]:
|
||||||
|
"""Get one or more story 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_ids (``int`` | Iterable of ``int``, *optional*):
|
||||||
|
Pass a single story identifier or an iterable of story ids (as integers) to get the content of the
|
||||||
|
story themselves.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.Story` | List of :obj:`~pyrogram.types.Story`: In case *story_ids* was not
|
||||||
|
a list, a single story is returned, otherwise a list of stories is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Get one story
|
||||||
|
await app.get_stories(user_id, 12345)
|
||||||
|
|
||||||
|
# Get more than one story (list of stories)
|
||||||
|
await app.get_stories(user_id, [12345, 12346])
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: In case of invalid arguments.
|
||||||
|
"""
|
||||||
|
|
||||||
|
peer = await self.resolve_peer(user_id)
|
||||||
|
|
||||||
|
is_iterable = not isinstance(story_ids, int)
|
||||||
|
ids = list(story_ids) if is_iterable else [story_ids]
|
||||||
|
|
||||||
|
rpc = raw.functions.stories.GetStoriesByID(user_id=peer, id=ids)
|
||||||
|
|
||||||
|
r = await self.invoke(rpc, sleep_threshold=-1)
|
||||||
|
|
||||||
|
if is_iterable:
|
||||||
|
return types.List([await types.Story._parse(self, story, user_id) for story in r.stories])
|
||||||
|
return await types.Story._parse(self, r.stories[0], user_id)
|
||||||
256
pyrogram/methods/users/send_story.py
Normal file
256
pyrogram/methods/users/send_story.py
Normal file
|
|
@ -0,0 +1,256 @@
|
||||||
|
# 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 os
|
||||||
|
import re
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import enums, raw, types, utils
|
||||||
|
from pyrogram.file_id import FileType
|
||||||
|
|
||||||
|
class SendStory:
|
||||||
|
def _split(self, message, entities, *args, **kwargs):
|
||||||
|
return message, entities
|
||||||
|
|
||||||
|
async def send_story(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
privacy: "enums.StoriesPrivacy" = None,
|
||||||
|
allowed_users: List[int] = None,
|
||||||
|
denied_users: List[int] = None,
|
||||||
|
allowed_chats: List[int] = None,
|
||||||
|
denied_chats: List[int] = None,
|
||||||
|
animation: str = None,
|
||||||
|
photo: str = None,
|
||||||
|
video: str = 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
|
||||||
|
) -> "types.Story":
|
||||||
|
"""Send new story.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users.rst
|
||||||
|
|
||||||
|
Note: You must pass one of following paramater *animation*, *photo*, *video*
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
animation (``str`` | ``BinaryIO``, *optional*):
|
||||||
|
Animation to send.
|
||||||
|
Pass a file_id as string to send a animation that exists on the Telegram servers,
|
||||||
|
pass an HTTP URL as a string for Telegram to get a animation from the Internet,
|
||||||
|
pass a file path as string to upload a new animation that exists on your local machine, or
|
||||||
|
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
|
||||||
|
|
||||||
|
photo (``str`` | ``BinaryIO``, *optional*):
|
||||||
|
Photo to send.
|
||||||
|
Pass a file_id as string to send a photo that exists on the Telegram servers,
|
||||||
|
pass an HTTP URL as a string for Telegram to get a photo from the Internet,
|
||||||
|
pass a file path as string to upload a new photo that exists on your local machine, or
|
||||||
|
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
|
||||||
|
|
||||||
|
video (``str`` | ``BinaryIO``, *optional*):
|
||||||
|
Video to send.
|
||||||
|
Pass a file_id as string to send a video that exists on the Telegram servers,
|
||||||
|
pass an HTTP URL as a string for Telegram to get a video from the Internet,
|
||||||
|
pass a file path as string to upload a new video that exists on your local machine, or
|
||||||
|
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
|
||||||
|
|
||||||
|
privacy (:obj:`~pyrogram.enums.StoriesPrivacy`, *optional*):
|
||||||
|
Story privacy.
|
||||||
|
Defaults to :obj:`~pyrogram.enums.StoriesPrivacy.PUBLIC`
|
||||||
|
|
||||||
|
allowed_chats (List of ``int``, *optional*):
|
||||||
|
List of chat_id which participant allowed to view the story.
|
||||||
|
|
||||||
|
denied_chats (List of ``int``, *optional*):
|
||||||
|
List of chat_id which participant denied to view the story.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Send new photo story
|
||||||
|
photo_id = "abcd12345"
|
||||||
|
await app.send_story(photo=photo_id, caption='Hello guys.')
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ValueError: In case of invalid arguments.
|
||||||
|
"""
|
||||||
|
# TODO: media_areas
|
||||||
|
|
||||||
|
if privacy:
|
||||||
|
privacy_rules = [types.StoriesPrivacy(type=privacy)]
|
||||||
|
else:
|
||||||
|
privacy_rules = [types.StoriesPrivacy(type=enums.StoriesPrivacy.PUBLIC)]
|
||||||
|
|
||||||
|
if animation:
|
||||||
|
if isinstance(animation, str):
|
||||||
|
if os.path.isfile(animation):
|
||||||
|
file = await self.save_file(animation)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(animation) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
),
|
||||||
|
raw.types.DocumentAttributeAnimated()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif re.match("^https?://", animation):
|
||||||
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
|
url=animation
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
media = utils.get_input_media_from_file_id(animation, FileType.ANIMATION)
|
||||||
|
else:
|
||||||
|
file = await self.save_file(animation)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(animation) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
),
|
||||||
|
raw.types.DocumentAttributeAnimated()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif photo:
|
||||||
|
if isinstance(photo, str):
|
||||||
|
if os.path.isfile(photo):
|
||||||
|
file = await self.save_file(photo)
|
||||||
|
media = raw.types.InputMediaUploadedPhoto(
|
||||||
|
file=file
|
||||||
|
)
|
||||||
|
elif re.match("^https?://", photo):
|
||||||
|
media = raw.types.InputMediaPhotoExternal(
|
||||||
|
url=photo
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
media = utils.get_input_media_from_file_id(photo, FileType.PHOTO)
|
||||||
|
else:
|
||||||
|
file = await self.save_file(photo)
|
||||||
|
media = raw.types.InputMediaUploadedPhoto(
|
||||||
|
file=file
|
||||||
|
)
|
||||||
|
elif video:
|
||||||
|
if isinstance(video, str):
|
||||||
|
if os.path.isfile(video):
|
||||||
|
file = await self.save_file(video)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(video) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
elif re.match("^https?://", video):
|
||||||
|
media = raw.types.InputMediaDocumentExternal(
|
||||||
|
url=video
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
media = utils.get_input_media_from_file_id(video, FileType.VIDEO)
|
||||||
|
else:
|
||||||
|
file = await self.save_file(video)
|
||||||
|
media = raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(video) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError("You need to pass one of the following parameter animation/photo/video!")
|
||||||
|
|
||||||
|
text, entities = self._split(**await utils.parse_text_entities(self, caption, parse_mode, caption_entities))
|
||||||
|
|
||||||
|
if allowed_chats and len(allowed_chats) > 0:
|
||||||
|
chats = [await self.resolve_peer(chat_id) for chat_id in allowed_chats]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueAllowChatParticipants(chats=chats))
|
||||||
|
if denied_chats and len(denied_chats) > 0:
|
||||||
|
chats = [await self.resolve_peer(chat_id) for chat_id in denied_chats]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueDisallowChatParticipants(chats=chats))
|
||||||
|
if allowed_users and len(allowed_users) > 0:
|
||||||
|
users = [await self.resolve_peer(user_id) for user_id in allowed_users]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueAllowUsers(users=users))
|
||||||
|
if denied_users and len(denied_users) > 0:
|
||||||
|
users = [await self.resolve_peer(user_id) for user_id in denied_users]
|
||||||
|
privacy_rules.append(raw.types.InputPrivacyValueDisallowUsers(users=users))
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.stories.SendStory(
|
||||||
|
media=media,
|
||||||
|
privacy_rules=privacy_rules,
|
||||||
|
random_id=self.rnd_id(),
|
||||||
|
pinned=pinned,
|
||||||
|
noforwards=protect_content,
|
||||||
|
caption=text,
|
||||||
|
entities=entities,
|
||||||
|
period=period
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return await types.Story._parse(self, r.updates[0].story, r.updates[0].user_id)
|
||||||
|
|
@ -19,8 +19,9 @@
|
||||||
|
|
||||||
from .input_message_content import InputMessageContent
|
from .input_message_content import InputMessageContent
|
||||||
from .input_reply_to_message import InputReplyToMessage
|
from .input_reply_to_message import InputReplyToMessage
|
||||||
|
from .input_reply_to_story import InputReplyToStory
|
||||||
from .input_text_message_content import InputTextMessageContent
|
from .input_text_message_content import InputTextMessageContent
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"InputMessageContent", "InputReplyToMessage", "InputTextMessageContent"
|
"InputMessageContent", "InputReplyToMessage", "InputReplyToStory", "InputTextMessageContent"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
49
pyrogram/types/input_message_content/input_reply_to_story.py
Normal file
49
pyrogram/types/input_message_content/input_reply_to_story.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# 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 ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class InputReplyToStory(Object):
|
||||||
|
"""Contains information about a target replied story.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
user_id (:obj:`~pyrogram.raw.types.InputUser`):
|
||||||
|
An InputUser.
|
||||||
|
|
||||||
|
story_id (``int``):
|
||||||
|
Unique identifier for the target story.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, *,
|
||||||
|
user_id: "raw.types.InputUser" = None,
|
||||||
|
story_id: int = None
|
||||||
|
):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.user_id = user_id
|
||||||
|
self.story_id = story_id
|
||||||
|
|
||||||
|
def write(self):
|
||||||
|
return raw.types.InputReplyToStory(
|
||||||
|
user_id=self.user_id,
|
||||||
|
story_id=self.story_id
|
||||||
|
).write()
|
||||||
|
|
@ -31,6 +31,7 @@ from .poll_option import PollOption
|
||||||
from .reaction import Reaction
|
from .reaction import Reaction
|
||||||
from .sticker import Sticker
|
from .sticker import Sticker
|
||||||
from .stickerset import StickerSet
|
from .stickerset import StickerSet
|
||||||
|
from .stories_privacy import StoriesPrivacy
|
||||||
from .stripped_thumbnail import StrippedThumbnail
|
from .stripped_thumbnail import StrippedThumbnail
|
||||||
from .thumbnail import Thumbnail
|
from .thumbnail import Thumbnail
|
||||||
from .venue import Venue
|
from .venue import Venue
|
||||||
|
|
@ -40,9 +41,12 @@ from .voice import Voice
|
||||||
from .web_app_data import WebAppData
|
from .web_app_data import WebAppData
|
||||||
from .web_page import WebPage
|
from .web_page import WebPage
|
||||||
from .message_reactions import MessageReactions
|
from .message_reactions import MessageReactions
|
||||||
|
from .story import Story
|
||||||
|
from .story_views import StoryViews
|
||||||
|
from .exported_story_link import ExportedStoryLink
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||||
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
||||||
"Reaction", "WebAppData", "MessageReactions"
|
"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)
|
||||||
|
)
|
||||||
47
pyrogram/types/messages_and_media/stories_privacy.py
Normal file
47
pyrogram/types/messages_and_media/stories_privacy.py
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# 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 enums, raw
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
class StoriesPrivacy(Object):
|
||||||
|
"""A story privacy.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
type (:obj:`~pyrogram.enums.StoriesPrivacy`):
|
||||||
|
Story privacy type.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, *,
|
||||||
|
type: "enums.StoriesPrivacy"
|
||||||
|
):
|
||||||
|
super().__init__()
|
||||||
|
self.type = type
|
||||||
|
|
||||||
|
def write(self):
|
||||||
|
if self.type == enums.StoriesPrivacy.PUBLIC:
|
||||||
|
return raw.types.InputPrivacyValueAllowAll().write()
|
||||||
|
if self.type == enums.StoriesPrivacy.CLOSE_FRIENDS:
|
||||||
|
return raw.types.InputPrivacyValueAllowCloseFriends().write()
|
||||||
|
if self.type == enums.StoriesPrivacy.CONTACTS:
|
||||||
|
return raw.types.InputPrivacyValueAllowContacts().write()
|
||||||
|
if self.type == enums.StoriesPrivacy.NO_CONTACTS:
|
||||||
|
return raw.types.InputPrivacyValueDisallowContacts().write()
|
||||||
|
if self.type == enums.StoriesPrivacy.PRIVATE:
|
||||||
|
return raw.types.InputPrivacyValueDisallowAll().write()
|
||||||
1638
pyrogram/types/messages_and_media/story.py
Normal file
1638
pyrogram/types/messages_and_media/story.py
Normal file
File diff suppressed because it is too large
Load diff
50
pyrogram/types/messages_and_media/story_views.py
Normal file
50
pyrogram/types/messages_and_media/story_views.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
# 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 StoryViews(Object):
|
||||||
|
"""Contains information about a story viewers.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
view_count (``int``):
|
||||||
|
The count of stories viewers.
|
||||||
|
|
||||||
|
recent_viewers (List of ``int``):
|
||||||
|
List of user_id of recent stories viewers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, *,
|
||||||
|
view_count: int,
|
||||||
|
recent_viewers: List[int] = None
|
||||||
|
):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.view_count = view_count
|
||||||
|
self.recent_viewers = recent_viewers
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(storyviews: "raw.types.StoryViews") -> "StoryViews":
|
||||||
|
return StoryViews(
|
||||||
|
view_count=getattr(storyviews,"view_count", None),
|
||||||
|
recent_viewers=getattr(storyviews,"recent_viewers", None)
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue