Add missing schedule_date to edit_message methods

This commit is contained in:
KurimuzonAkuma 2023-12-15 23:08:08 +03:00
parent 382eed220a
commit 298a39468b
4 changed files with 25 additions and 0 deletions

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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
)

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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

View File

@ -16,11 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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,
)
)

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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)
)