Skip to content

Commit

Permalink
Added the field reply_to_story to the class Message.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Feb 22, 2024
1 parent 3713048 commit 579053f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ it can take advantage of new goodies!
| Leaked Scheme layer |
+------------------------+

- Added the field ``reply_to_story`` to the class :obj:`~pyrogram.types.Message`.
- Added the field ``user_chat_id`` to the class :obj:`~pyrogram.types.ChatJoinRequest`.
- Added the field ``switch_inline_query_chosen_chat`` of the type :obj:`~pyrogram.types.SwitchInlineQueryChosenChat` to the class :obj:`~pyrogram.types.InlineKeyboardButton`, which allows bots to switch to inline mode in a chosen chat of the given type.
- Add support for ``pay`` in :obj:`~pyrogram.types.InlineKeyboardButton`
Expand Down
12 changes: 7 additions & 5 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def __init__(
reply_to_message: "Message" = None,
external_reply: "types.ExternalReplyInfo" = None,

reply_to_story: "types.Story" = None,
via_bot: "types.User" = None,
edit_date: datetime = None,
has_protected_content: bool = None,
Expand Down Expand Up @@ -563,6 +564,7 @@ def __init__(
self.sender_boost_count = sender_boost_count
self.boost_added = boost_added
self.story = story
self.reply_to_story = reply_to_story
self._raw = _raw

@staticmethod
Expand Down Expand Up @@ -911,7 +913,7 @@ async def _parse(
dice = types.Dice._parse(client, media)
media_type = enums.MessageMediaType.DICE
elif isinstance(media, raw.types.MessageMediaStory):
story = await types.Story._parse(client, chats, media)
story = await types.Story._parse(client, chats, media, None)
media_type = enums.MessageMediaType.STORY
else:
media = None
Expand Down Expand Up @@ -1019,8 +1021,11 @@ async def _parse(
if isinstance(message.reply_to, raw.types.MessageReplyHeader):
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
parsed_message.message_thread_id = message.reply_to.reply_to_top_id
if message.reply_to.forum_topic:
parsed_message.is_topic_message = True

if isinstance(message.reply_to, raw.types.MessageReplyStoryHeader):
parsed_message.reply_to_message_id = message.reply_to.story_id
parsed_message.reply_to_story = await types.Story._parse(client, chats, None, message.reply_to)

if replies:
try:
Expand All @@ -1038,9 +1043,6 @@ async def _parse(
except MessageIdsEmpty:
pass

if message.reply_to.forum_topic:
parsed_message.is_topic_message = True

parsed_message.external_reply = await types.ExternalReplyInfo._parse(
client,
message.reply_to
Expand Down
20 changes: 14 additions & 6 deletions pyrogram/types/messages_and_media/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,24 @@ def __init__(
async def _parse(
client,
chats: dict,
story_media: "raw.types.MessageMediaStory"
story_media: "raw.types.MessageMediaStory",
reply_story: "raw.types.MessageReplyStoryHeader"
) -> "Video":
story_id = None
chat = None
if story_media.peer:
raw_peer_id = utils.get_peer_id(story_media.peer)
chat = await client.get_chat(raw_peer_id)

if story_media:
if story_media.peer:
raw_peer_id = utils.get_peer_id(story_media.peer)
chat = await client.get_chat(raw_peer_id)
story_id = getattr(story_media, "id", None)
if reply_story:
if reply_story.peer:
raw_peer_id = utils.get_peer_id(reply_story.peer)
chat = await client.get_chat(raw_peer_id)
story_id = getattr(reply_story, "story_id", None)
return Story(
client=client,
_raw=story_media,
id=getattr(story_media, "id", None),
id=story_id,
chat=chat
)

0 comments on commit 579053f

Please sign in to comment.