mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Add support for scheduled forward messages
This commit is contained in:
parent
72e150ca13
commit
e42d6acc08
@ -31,7 +31,8 @@ class ForwardMessages(BaseClient):
|
|||||||
message_ids: Union[int, Iterable[int]],
|
message_ids: Union[int, Iterable[int]],
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
as_copy: bool = False,
|
as_copy: bool = False,
|
||||||
remove_caption: bool = False
|
remove_caption: bool = False,
|
||||||
|
schedule_date: int = None
|
||||||
) -> List["pyrogram.Message"]:
|
) -> List["pyrogram.Message"]:
|
||||||
"""Forward messages of any kind.
|
"""Forward messages of any kind.
|
||||||
|
|
||||||
@ -64,6 +65,9 @@ class ForwardMessages(BaseClient):
|
|||||||
message. Has no effect if *as_copy* is not enabled.
|
message. Has no effect if *as_copy* is not enabled.
|
||||||
Defaults to False.
|
Defaults to False.
|
||||||
|
|
||||||
|
schedule_date (``int``, *optional*):
|
||||||
|
Date when the message will be automatically sent. Unix time.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
:obj:`Message` | List of :obj:`Message`: In case *message_ids* was an integer, the single forwarded message
|
:obj:`Message` | List of :obj:`Message`: In case *message_ids* was an integer, the single forwarded message
|
||||||
is returned, otherwise, in case *message_ids* was an iterable, the returned value will be a list of
|
is returned, otherwise, in case *message_ids* was an iterable, the returned value will be a list of
|
||||||
@ -98,7 +102,8 @@ class ForwardMessages(BaseClient):
|
|||||||
chat_id,
|
chat_id,
|
||||||
disable_notification=disable_notification,
|
disable_notification=disable_notification,
|
||||||
as_copy=True,
|
as_copy=True,
|
||||||
remove_caption=remove_caption
|
remove_caption=remove_caption,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,7 +115,8 @@ class ForwardMessages(BaseClient):
|
|||||||
from_peer=self.resolve_peer(from_chat_id),
|
from_peer=self.resolve_peer(from_chat_id),
|
||||||
id=message_ids,
|
id=message_ids,
|
||||||
silent=disable_notification or None,
|
silent=disable_notification or None,
|
||||||
random_id=[self.rnd_id() for _ in message_ids]
|
random_id=[self.rnd_id() for _ in message_ids],
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2634,7 +2634,8 @@ class Message(Object, Update):
|
|||||||
chat_id: int or str,
|
chat_id: int or str,
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
as_copy: bool = False,
|
as_copy: bool = False,
|
||||||
remove_caption: bool = False
|
remove_caption: bool = False,
|
||||||
|
schedule_date: int = None
|
||||||
) -> "Message":
|
) -> "Message":
|
||||||
"""Bound method *forward* of :obj:`Message`.
|
"""Bound method *forward* of :obj:`Message`.
|
||||||
|
|
||||||
@ -2672,6 +2673,9 @@ class Message(Object, Update):
|
|||||||
message. Has no effect if *as_copy* is not enabled.
|
message. Has no effect if *as_copy* is not enabled.
|
||||||
Defaults to False.
|
Defaults to False.
|
||||||
|
|
||||||
|
schedule_date (``int``, *optional*):
|
||||||
|
Date when the message will be automatically sent. Unix time.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the forwarded Message is returned.
|
On success, the forwarded Message is returned.
|
||||||
|
|
||||||
@ -2691,7 +2695,8 @@ class Message(Object, Update):
|
|||||||
text=self.text.html,
|
text=self.text.html,
|
||||||
parse_mode="html",
|
parse_mode="html",
|
||||||
disable_web_page_preview=not self.web_page,
|
disable_web_page_preview=not self.web_page,
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
elif self.media:
|
elif self.media:
|
||||||
caption = self.caption.html if self.caption and not remove_caption else ""
|
caption = self.caption.html if self.caption and not remove_caption else ""
|
||||||
@ -2699,7 +2704,8 @@ class Message(Object, Update):
|
|||||||
send_media = partial(
|
send_media = partial(
|
||||||
self._client.send_cached_media,
|
self._client.send_cached_media,
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.photo:
|
if self.photo:
|
||||||
@ -2733,14 +2739,16 @@ class Message(Object, Update):
|
|||||||
first_name=self.contact.first_name,
|
first_name=self.contact.first_name,
|
||||||
last_name=self.contact.last_name,
|
last_name=self.contact.last_name,
|
||||||
vcard=self.contact.vcard,
|
vcard=self.contact.vcard,
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
elif self.location:
|
elif self.location:
|
||||||
return self._client.send_location(
|
return self._client.send_location(
|
||||||
chat_id,
|
chat_id,
|
||||||
latitude=self.location.latitude,
|
latitude=self.location.latitude,
|
||||||
longitude=self.location.longitude,
|
longitude=self.location.longitude,
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
elif self.venue:
|
elif self.venue:
|
||||||
return self._client.send_venue(
|
return self._client.send_venue(
|
||||||
@ -2751,14 +2759,16 @@ class Message(Object, Update):
|
|||||||
address=self.venue.address,
|
address=self.venue.address,
|
||||||
foursquare_id=self.venue.foursquare_id,
|
foursquare_id=self.venue.foursquare_id,
|
||||||
foursquare_type=self.venue.foursquare_type,
|
foursquare_type=self.venue.foursquare_type,
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
elif self.poll:
|
elif self.poll:
|
||||||
return self._client.send_poll(
|
return self._client.send_poll(
|
||||||
chat_id,
|
chat_id,
|
||||||
question=self.poll.question,
|
question=self.poll.question,
|
||||||
options=[opt.text for opt in self.poll.options],
|
options=[opt.text for opt in self.poll.options],
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
elif self.game:
|
elif self.game:
|
||||||
return self._client.send_game(
|
return self._client.send_game(
|
||||||
@ -2780,7 +2790,8 @@ class Message(Object, Update):
|
|||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
from_chat_id=self.chat.id,
|
from_chat_id=self.chat.id,
|
||||||
message_ids=self.message_id,
|
message_ids=self.message_id,
|
||||||
disable_notification=disable_notification
|
disable_notification=disable_notification,
|
||||||
|
schedule_date=schedule_date
|
||||||
)
|
)
|
||||||
|
|
||||||
def delete(self, revoke: bool = True):
|
def delete(self, revoke: bool = True):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user