From 298a39468b49359431c24d3c2cc64c6e54ea1fdd Mon Sep 17 00:00:00 2001 From: KurimuzonAkuma Date: Fri, 15 Dec 2023 23:08:08 +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 2e4a45a6..9a8290b7 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 @@ class EditMessageCaption: 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 @@ class EditMessageCaption: 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 @@ class EditMessageCaption: 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 72f0bd9a..2056f78f 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 @@ class EditMessageMedia: 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 @@ class EditMessageMedia: 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 @@ class EditMessageMedia: 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 1cd75c1a..42a631cb 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 @@ class EditMessageReplyMarkup: 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 @@ class EditMessageReplyMarkup: 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 @@ class EditMessageReplyMarkup: 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 540b6aa6..66868c98 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 @@ class EditMessageText: 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 @@ class EditMessageText: 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 @@ class EditMessageText: 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) )