Skip to content

Commit

Permalink
Pyrofork: Add business_connection_id parameter to edit_message_{text,…
Browse files Browse the repository at this point in the history
…caption} methods

Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Apr 6, 2024
1 parent 59f88be commit 007f6e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pyrogram/methods/messages/edit_message_caption.py
Expand Up @@ -29,6 +29,7 @@ async def edit_message_caption(
chat_id: Union[int, str],
message_id: int,
caption: str,
business_connection_id: str = None,
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: List["types.MessageEntity"] = None,
reply_markup: "types.InlineKeyboardMarkup" = None
Expand All @@ -50,6 +51,10 @@ async def edit_message_caption(
caption (``str``):
New caption of the media message.
business_connection_id (``str``, *optional*):
Business connection identifier.
for business bots only.
parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
By default, texts are parsed using both Markdown and HTML styles.
You can combine both syntaxes together.
Expand All @@ -72,6 +77,7 @@ async def edit_message_caption(
chat_id=chat_id,
message_id=message_id,
text=caption,
business_connection_id=business_connection_id,
parse_mode=parse_mode,
entities=caption_entities,
reply_markup=reply_markup
Expand Down
28 changes: 20 additions & 8 deletions pyrogram/methods/messages/edit_message_text.py
Expand Up @@ -31,6 +31,7 @@ async def edit_message_text(
chat_id: Union[int, str],
message_id: int,
text: str,
business_connection_id: str = None,
parse_mode: Optional["enums.ParseMode"] = None,
entities: List["types.MessageEntity"] = None,
disable_web_page_preview: bool = None,
Expand All @@ -53,6 +54,10 @@ async def edit_message_text(
text (``str``):
New text of the message.
business_connection_id (``str``, *optional*):
Business connection identifier.
for business bots only.
parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
By default, texts are parsed using both Markdown and HTML styles.
You can combine both syntaxes together.
Expand Down Expand Up @@ -81,15 +86,22 @@ async def edit_message_text(
disable_web_page_preview=True)
"""

r = await self.invoke(
raw.functions.messages.EditMessage(
peer=await self.resolve_peer(chat_id),
id=message_id,
no_webpage=disable_web_page_preview or None,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, text, parse_mode, entities)
)
rpc = raw.functions.messages.EditMessage(
peer=await self.resolve_peer(chat_id),
id=message_id,
no_webpage=disable_web_page_preview or None,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, text, parse_mode, entities)
)
if business_connection_id:
r = await self.invoke(
raw.functions.InvokeWithBusinessConnection(
connection_id=business_connection_id,
query=rpc
)
)
else:
r = await self.invoke(rpc)

for i in r.updates:
if isinstance(i, (raw.types.UpdateEditMessage, raw.types.UpdateEditChannelMessage)):
Expand Down

0 comments on commit 007f6e3

Please sign in to comment.