From f72a19f49394a613d94b5c1cfd4dc934a5a7cd99 Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Fri, 15 Dec 2023 20:41:06 +0300 Subject: [PATCH] Add missing schedule_date to edit_message methods --- pyrogram/methods/messages/edit_message_caption.py | 6 ++++++ pyrogram/methods/messages/edit_message_media.py | 6 ++++++ pyrogram/methods/messages/edit_message_reply_markup.py | 7 +++++++ pyrogram/methods/messages/edit_message_text.py | 6 ++++++ 4 files changed, 25 insertions(+) diff --git a/pyrogram/methods/messages/edit_message_caption.py b/pyrogram/methods/messages/edit_message_caption.py index 2e4a45a694a..9a8290b797f 100644 --- a/pyrogram/methods/messages/edit_message_caption.py +++ b/pyrogram/methods/messages/edit_message_caption.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from datetime import datetime from typing import Union, List, Optional import pyrogram @@ -30,6 +31,7 @@ async def edit_message_caption( caption: str, parse_mode: Optional["enums.ParseMode"] = None, caption_entities: List["types.MessageEntity"] = None, + schedule_date: datetime = None, reply_markup: "types.InlineKeyboardMarkup" = None ) -> "types.Message": """Edit the caption of media messages. @@ -55,6 +57,9 @@ async def edit_message_caption( 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*. + schedule_date (:py:obj:`~datetime.datetime`, *optional*): + Date when the message will be automatically sent. + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. @@ -72,5 +77,6 @@ async def edit_message_caption( text=caption, parse_mode=parse_mode, entities=caption_entities, + schedule_date=schedule_date, reply_markup=reply_markup ) diff --git a/pyrogram/methods/messages/edit_message_media.py b/pyrogram/methods/messages/edit_message_media.py index 72f0bd9ac0f..2056f78f75f 100644 --- a/pyrogram/methods/messages/edit_message_media.py +++ b/pyrogram/methods/messages/edit_message_media.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from datetime import datetime import io import os import re @@ -35,6 +36,7 @@ async def edit_message_media( message_id: int, media: "types.InputMedia", invert_media: bool = None, + schedule_date: datetime = None, reply_markup: "types.InlineKeyboardMarkup" = None, file_name: str = None ) -> "types.Message": @@ -60,6 +62,9 @@ async def edit_message_media( invert_media (``bool``, *optional*): Invert media. + schedule_date (:py:obj:`~datetime.datetime`, *optional*): + Date when the message will be automatically sent. + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. @@ -277,6 +282,7 @@ async def edit_message_media( id=message_id, invert_media=invert_media, media=media, + schedule_date=utils.datetime_to_timestamp(schedule_date), reply_markup=await reply_markup.write(self) if reply_markup else None, message=message, entities=entities diff --git a/pyrogram/methods/messages/edit_message_reply_markup.py b/pyrogram/methods/messages/edit_message_reply_markup.py index 1cd75c1a8b5..42a631cbecb 100644 --- a/pyrogram/methods/messages/edit_message_reply_markup.py +++ b/pyrogram/methods/messages/edit_message_reply_markup.py @@ -16,11 +16,13 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from datetime import datetime from typing import Union import pyrogram from pyrogram import raw from pyrogram import types +from pyrogram import utils class EditMessageReplyMarkup: @@ -28,6 +30,7 @@ async def edit_message_reply_markup( self: "pyrogram.Client", chat_id: Union[int, str], message_id: int, + schedule_date: datetime = None, reply_markup: "types.InlineKeyboardMarkup" = None, ) -> "types.Message": """Edit only the reply markup of messages sent by the bot. @@ -43,6 +46,9 @@ async def edit_message_reply_markup( message_id (``int``): Message identifier in the chat specified in chat_id. + schedule_date (:py:obj:`~datetime.datetime`, *optional*): + Date when the message will be automatically sent. + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. @@ -64,6 +70,7 @@ async def edit_message_reply_markup( raw.functions.messages.EditMessage( peer=await self.resolve_peer(chat_id), id=message_id, + schedule_date=utils.datetime_to_timestamp(schedule_date), reply_markup=await reply_markup.write(self) if reply_markup else None, ) ) diff --git a/pyrogram/methods/messages/edit_message_text.py b/pyrogram/methods/messages/edit_message_text.py index 540b6aa63ce..66868c984cb 100644 --- a/pyrogram/methods/messages/edit_message_text.py +++ b/pyrogram/methods/messages/edit_message_text.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from datetime import datetime from typing import Union, List, Optional import pyrogram @@ -33,6 +34,7 @@ async def edit_message_text( parse_mode: Optional["enums.ParseMode"] = None, entities: List["types.MessageEntity"] = None, disable_web_page_preview: bool = None, + schedule_date: datetime = None, reply_markup: "types.InlineKeyboardMarkup" = None ) -> "types.Message": """Edit the text of messages. @@ -61,6 +63,9 @@ async def edit_message_text( disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. + schedule_date (:py:obj:`~datetime.datetime`, *optional*): + Date when the message will be automatically sent. + reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. @@ -84,6 +89,7 @@ async def edit_message_text( peer=await self.resolve_peer(chat_id), id=message_id, no_webpage=disable_web_page_preview or None, + schedule_date=utils.datetime_to_timestamp(schedule_date), reply_markup=await reply_markup.write(self) if reply_markup else None, **await utils.parse_text_entities(self, text, parse_mode, entities) )