Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f64d0c7
InputStoryContent
SpEcHiDe Apr 15, 2025
c822df0
copy code
SpEcHiDe Apr 17, 2025
5d96d5a
fixes
SpEcHiDe Apr 17, 2025
40dd9e8
testign
SpEcHiDe Apr 17, 2025
2f104a9
privacy_settings
SpEcHiDe Apr 18, 2025
2d595fa
Add delete_stories and delete_story
SpEcHiDe Apr 18, 2025
ea30bec
Update delete_stories.py
SpEcHiDe Apr 18, 2025
baec11f
https://github.com/KurimuzonAkuma/pyrogram/commit/8a49a12
SpEcHiDe Apr 26, 2025
67c8925
StoryArea
SpEcHiDe Apr 27, 2025
323a918
StoryAreaPosition
SpEcHiDe Apr 28, 2025
fd3e204
maybe areas
SpEcHiDe Apr 28, 2025
e0dfeda
docs
SpEcHiDe Apr 28, 2025
3d36bfd
docs
SpEcHiDe Apr 28, 2025
7e08b39
add testing code
SpEcHiDe Apr 28, 2025
73ae490
fixes
SpEcHiDe Apr 28, 2025
f163483
edit_story
SpEcHiDe Apr 28, 2025
40ed230
Merge branch 'dev' into stories-9.0
SpEcHiDe Apr 28, 2025
5dc19c2
Update input_story_content_video.py
SpEcHiDe Apr 28, 2025
3380cba
Add StoryAreaTypeFoundVenue and StoryAreaTypeMessage
SpEcHiDe Apr 29, 2025
e0eb531
fix default value
SpEcHiDe Apr 29, 2025
e95b241
docs
SpEcHiDe Apr 29, 2025
ea8a7d8
refactor Story types
SpEcHiDe Apr 29, 2025
257757b
...
SpEcHiDe Apr 29, 2025
1f467c3
Merge branch 'dev' into stories-9.0
SpEcHiDe May 1, 2025
06fcb15
Updated terminology from "send stories" to "post stories" throughout …
SpEcHiDe May 1, 2025
2769020
docs
SpEcHiDe May 5, 2025
181e916
fixes
SpEcHiDe May 5, 2025
cef4a4f
Add can_post_story
SpEcHiDe May 5, 2025
ff819b6
Add activate_story_stealth_mode
SpEcHiDe May 5, 2025
96dd852
Rename activate_story_stealth_mode to hide_my_story_view
SpEcHiDe May 6, 2025
db13817
Add StoryStealthMode
SpEcHiDe May 6, 2025
9021d84
Add support for parseing story link in get_messages
SpEcHiDe May 6, 2025
4e3e54e
Add forward_story
SpEcHiDe May 7, 2025
60f40ab
rename :\
SpEcHiDe May 7, 2025
5d91ba1
Add toggle_story_is_posted_to_chat_page
SpEcHiDe May 7, 2025
f4e1bd6
fixes
SpEcHiDe May 7, 2025
befae23
testing
SpEcHiDe May 7, 2025
41ba85d
Try to parse privacy_settings (1/n)
SpEcHiDe May 8, 2025
e9bbb47
Remove some of the parameters from forward_story
SpEcHiDe May 8, 2025
134c641
Add get_chat_active_stories
SpEcHiDe May 8, 2025
70d90c0
Merge branch 'dev' into stories-9.0
SpEcHiDe May 8, 2025
be39af6
Add get_chat_archived_stories
SpEcHiDe May 8, 2025
11177fd
Merge branch 'dev' into stories-9.0
SpEcHiDe May 8, 2025
baa4d4c
(fix): NameError
SpEcHiDe May 8, 2025
7cb7b88
(fix): privacy_settings
SpEcHiDe May 8, 2025
2272f40
test docs
SpEcHiDe May 8, 2025
b18fe01
fixes
SpEcHiDe May 8, 2025
44816f2
rename
SpEcHiDe May 8, 2025
e63849e
Add StoryRepostInfo
SpEcHiDe May 8, 2025
c9ce8f5
fix1
SpEcHiDe May 8, 2025
ad5e6f2
fix2
SpEcHiDe May 8, 2025
258aefb
Add story_count to CanPostStoryResultOk
SpEcHiDe May 9, 2025
a62d88e
@CoPilot review comments
SpEcHiDe May 9, 2025
e188a6e
docs
SpEcHiDe May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,18 @@ def get_title_list(s: str) -> list:
""",
stories="""
Stories
can_post_story
get_stories
get_chat_active_stories
get_chat_archived_stories
post_story
edit_story
edit_business_story
delete_stories
delete_business_story
hide_my_story_view
forward_story
toggle_story_is_posted_to_chat_page
""",
payments="""
Payments
Expand Down Expand Up @@ -691,7 +702,41 @@ def get_title_list(s: str) -> list:
PaidReactionTypeAnonymous
PaidReactionTypeChat
PaidReactionTypeRegular
"""
""",
stories="""
Stories
CanPostStoryResult
CanPostStoryResultOk
CanPostStoryResultPremiumNeeded
CanPostStoryResultBoostNeeded
CanPostStoryResultActiveStoryLimitExceeded
CanPostStoryResultWeeklyLimitExceeded
CanPostStoryResultMonthlyLimitExceeded
InputStoryContent
InputStoryContentPhoto
InputStoryContentVideo
StoryAreaPosition
LocationAddress
StoryAreaType
StoryAreaTypeFoundVenue
StoryAreaTypeLocation
StoryAreaTypeSuggestedReaction
StoryAreaTypeLink
StoryAreaTypeMessage
StoryAreaTypeWeather
StoryAreaTypeUniqueGift
StoryArea
StoryRepostInfo
StoryOrigin
StoryOriginHiddenUser
StoryOriginPublicStory
StoryPrivacySettings
StoryPrivacySettingsEveryone
StoryPrivacySettingsContacts
StoryPrivacySettingsCloseFriends
StoryPrivacySettingsSelectedUsers
StoryStealthMode
""",
)

root = PYROGRAM_API_DEST + "/types"
Expand Down
13 changes: 13 additions & 0 deletions compiler/docs/template/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,16 @@ Payments
:hidden:

{payments}

Stories
--------

.. autosummary::
:nosignatures:

{stories}

.. toctree::
:hidden:

{stories}
8 changes: 8 additions & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ Changes in this Fork
| Scheme layer used: 202 |
+------------------------+

- Added the method :meth:`~pyrogram.Client.post_story` allowing bots to post a story on behalf of a managed business account.
- Added the method :meth:`~pyrogram.Client.edit_story` and :meth:`~pyrogram.Client.edit_business_story`, allowing bots to edit stories they had previously posted on behalf of a managed business account.
- Added the methods :meth:`~pyrogram.Client.delete_stories` and :meth:`~pyrogram.Client.delete_business_story`, allowing bots to delete stories they had previously posted on behalf of a managed business account.
- Added the classes :obj:`~pyrogram.types.InputStoryContentPhoto` and :obj:`~pyrogram.types.InputStoryContentVideo` representing the content of a story to post.
- Added the classes :obj:`~pyrogram.types.StoryArea`, :obj:`~pyrogram.types.StoryAreaPosition`, :obj:`~pyrogram.types.LocationAddress`, :obj:`~pyrogram.types.StoryAreaTypeLocation`, :obj:`~pyrogram.types.StoryAreaTypeSuggestedReaction`, :obj:`~pyrogram.types.StoryAreaTypeLink`, :obj:`~pyrogram.types.StoryAreaTypeWeather`, :obj:`~pyrogram.types.StoryAreaTypeUniqueGift`, :obj:`~pyrogram.types.StoryAreaTypeFoundVenue` and :obj:`~pyrogram.types.StoryAreaTypeMessage` describing clickable active areas on stories.
- Added the classes :obj:`~pyrogram.types.StoryPrivacySettings`, :obj:`~pyrogram.types.StoryPrivacySettingsEveryone`, :obj:`~pyrogram.types.StoryPrivacySettingsContacts`, :obj:`~pyrogram.types.StoryPrivacySettingsCloseFriends`, :obj:`~pyrogram.types.StoryPrivacySettingsSelectedUsers` to describe the privacy settings of a story.
- Added the methods :meth:`~pyrogram.Client.can_post_story`, :meth:`~pyrogram.Client.hide_my_story_view`, :meth:`~pyrogram.Client.forward_story`, :meth:`~pyrogram.Client.toggle_story_is_posted_to_chat_page`, :meth:`~pyrogram.Client.get_chat_active_stories`, :meth:`~pyrogram.Client.get_chat_archived_stories`.
- Add support for parsing story links in :meth:`~pyrogram.Client.get_messages`.
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=201&to=202>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=200&to=202>`__.

+------------------------+
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/business/get_owned_star_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ async def get_business_account_star_balance(
if not business_connection_id:
raise ValueError("business_connection_id is required")

business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
r = await self.invoke(
raw.functions.InvokeWithBusinessConnection(
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/chats/pin_chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def pin_chat_message(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/chats/unpin_chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ async def unpin_chat_message(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ async def edit_cached_media(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_message_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ async def edit_message_media(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_message_reply_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ async def edit_message_reply_markup(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/edit_message_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ async def edit_message_text(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
24 changes: 23 additions & 1 deletion pyrogram/methods/messages/get_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,28 @@ async def get_messages(
int(linkps[4])
)
message_id = int(linkps[5])
elif linkps[4] == "s":
# https://t.me/yehudalev/s/1
if (
self.me and
self.me.is_bot
):
raise ValueError(
"Invalid ClientType used to parse this story link"
)
raw_chat_id = linkps[3]
story_id = int(linkps[5])

story = await self.get_stories(
story_poster_chat_id=raw_chat_id,
story_ids=story_id
)
return types.Message(
client=self,
id=0,
story=story,
empty=True
)
else:
# https://t.me/TheForum/322/487
raw_chat_id = linkps[3]
Expand Down Expand Up @@ -192,7 +214,7 @@ async def get_messages(
raw_chat_id = linkps[3]
if raw_chat_id == "m":
raise ValueError(
"Invalid ClientType used to parse this message link"
"Invalid ClientType used to parse this link to start chat"
)
message_id = int(linkps[4])

Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ async def progress(current, total):
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ async def progress(current, total):
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ async def progress(current, total):
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ async def send_media_group(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ async def send_message(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_paid_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ async def send_paid_media(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ async def send_photo(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ async def send_sticker(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ async def progress(current, total):
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_video_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ async def send_video_note(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/send_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ async def send_voice(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/messages/stop_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ async def stop_poll(
session = None
business_connection = None
if business_connection_id:
business_connection = self.business_user_connection_cache[business_connection_id]
if not business_connection:
business_connection = self.business_user_connection_cache.get(business_connection_id)
if business_connection is None:
business_connection = await self.get_business_connection(business_connection_id)
session = await get_session(
self,
Expand Down
20 changes: 19 additions & 1 deletion pyrogram/methods/stories/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2017-present <https://github.com/TelegramPlayGround>
#
# This file is part of Pyrogram.
#
Expand All @@ -17,9 +17,27 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.


from .can_post_story import CanPostStory
from .delete_stories import DeleteStories
from .edit_story import EditStory
from .forward_story import ForwardStory
from .get_chat_active_stories import GetChatActiveStories
from .get_chat_archived_stories import GetChatArchivedStories
from .get_stories import GetStories
from .hide_my_story_view import HideMyStoryView
from .post_story import PostStory
from .toggle_story_is_posted_to_chat_page import ToggleStoryIsPostedToChatPage

class Stories(
CanPostStory,
DeleteStories,
EditStory,
ForwardStory,
GetChatActiveStories,
GetChatArchivedStories,
GetStories,
HideMyStoryView,
PostStory,
ToggleStoryIsPostedToChatPage,
):
pass
Loading