mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-05 00:35:10 +00:00
Merge develop -> asyncio-dev
This commit is contained in:
@@ -32,7 +32,8 @@ class ForwardMessages(BaseClient):
|
||||
message_ids: Union[int, Iterable[int]],
|
||||
disable_notification: bool = None,
|
||||
as_copy: bool = False,
|
||||
remove_caption: bool = False
|
||||
remove_caption: bool = False,
|
||||
schedule_date: int = None
|
||||
) -> List["pyrogram.Message"]:
|
||||
"""Forward messages of any kind.
|
||||
|
||||
@@ -65,6 +66,9 @@ class ForwardMessages(BaseClient):
|
||||
message. Has no effect if *as_copy* is not enabled.
|
||||
Defaults to False.
|
||||
|
||||
schedule_date (``int``, *optional*):
|
||||
Date when the message will be automatically sent. Unix time.
|
||||
|
||||
Returns:
|
||||
: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
|
||||
@@ -99,7 +103,8 @@ class ForwardMessages(BaseClient):
|
||||
chat_id,
|
||||
disable_notification=disable_notification,
|
||||
as_copy=True,
|
||||
remove_caption=remove_caption
|
||||
remove_caption=remove_caption,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
)
|
||||
|
||||
@@ -111,7 +116,8 @@ class ForwardMessages(BaseClient):
|
||||
from_peer=await self.resolve_peer(from_chat_id),
|
||||
id=message_ids,
|
||||
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
|
||||
)
|
||||
)
|
||||
|
||||
@@ -121,7 +127,7 @@ class ForwardMessages(BaseClient):
|
||||
chats = {i.id: i for i in r.chats}
|
||||
|
||||
for i in r.updates:
|
||||
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
|
||||
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage, types.UpdateNewScheduledMessage)):
|
||||
forwarded_messages.append(
|
||||
await pyrogram.Message._parse(
|
||||
self, i.message,
|
||||
|
@@ -27,6 +27,7 @@ class SendDice(BaseClient):
|
||||
async def send_dice(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
emoji: str = "🎲",
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None,
|
||||
schedule_date: int = None,
|
||||
@@ -45,6 +46,10 @@ class SendDice(BaseClient):
|
||||
For your personal cloud (Saved Messages) you can simply use "me" or "self".
|
||||
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||
|
||||
emoji (``str``, *optional*):
|
||||
Emoji on which the dice throw animation is based. Currently, must be one of "🎲" or "🎯".
|
||||
Defauts to "🎲".
|
||||
|
||||
disable_notification (``bool``, *optional*):
|
||||
Sends the message silently.
|
||||
Users will receive a notification with no sound.
|
||||
@@ -65,13 +70,17 @@ class SendDice(BaseClient):
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
# Send a dice
|
||||
app.send_dice("pyrogramlounge")
|
||||
|
||||
# Send a dart
|
||||
app.send_dice("pyrogramlounge", "🎯")
|
||||
"""
|
||||
|
||||
r = await self.send(
|
||||
functions.messages.SendMedia(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
media=types.InputMediaDice(),
|
||||
media=types.InputMediaDice(emoticon=emoji),
|
||||
silent=disable_notification or None,
|
||||
reply_to_msg_id=reply_to_message_id,
|
||||
random_id=self.rnd_id(),
|
||||
|
@@ -27,18 +27,26 @@ from ...ext.utils import encode_file_id, encode_file_ref
|
||||
|
||||
|
||||
class Dice(Object):
|
||||
"""A dice containing a value that is randomly generated by Telegram.
|
||||
"""A dice with a random value from 1 to 6 for currently supported base emoji.
|
||||
|
||||
Parameters:
|
||||
emoji (``string``):
|
||||
Emoji on which the dice throw animation is based.
|
||||
|
||||
value (``int``):
|
||||
Dice value, 1-6.
|
||||
Value of the dice, 1-6 for currently supported base emoji.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client: "pyrogram.BaseClient" = None, value: int):
|
||||
def __init__(self, *, client: "pyrogram.BaseClient" = None, emoji: str, value: int):
|
||||
super().__init__(client)
|
||||
|
||||
self.emoji = emoji
|
||||
self.value = value
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, dice: types.MessageMediaDice) -> "Dice":
|
||||
return Dice(value=dice.value, client=client)
|
||||
return Dice(
|
||||
emoji=dice.emoticon,
|
||||
value=dice.value,
|
||||
client=client
|
||||
)
|
||||
|
@@ -561,7 +561,8 @@ class Message(Object, Update):
|
||||
if video_attributes.round_message:
|
||||
video_note = pyrogram.VideoNote._parse(client, doc, video_attributes)
|
||||
else:
|
||||
video = pyrogram.Video._parse(client, doc, video_attributes, file_name)
|
||||
video = pyrogram.Video._parse(client, doc, video_attributes, file_name,
|
||||
media.ttl_seconds)
|
||||
elif types.DocumentAttributeSticker in attributes:
|
||||
sticker = await pyrogram.Sticker._parse(
|
||||
client, doc,
|
||||
@@ -2633,7 +2634,8 @@ class Message(Object, Update):
|
||||
chat_id: int or str,
|
||||
disable_notification: bool = None,
|
||||
as_copy: bool = False,
|
||||
remove_caption: bool = False
|
||||
remove_caption: bool = False,
|
||||
schedule_date: int = None
|
||||
) -> "Message":
|
||||
"""Bound method *forward* of :obj:`Message`.
|
||||
|
||||
@@ -2671,6 +2673,9 @@ class Message(Object, Update):
|
||||
message. Has no effect if *as_copy* is not enabled.
|
||||
Defaults to False.
|
||||
|
||||
schedule_date (``int``, *optional*):
|
||||
Date when the message will be automatically sent. Unix time.
|
||||
|
||||
Returns:
|
||||
On success, the forwarded Message is returned.
|
||||
|
||||
@@ -2690,7 +2695,8 @@ class Message(Object, Update):
|
||||
text=self.text.html,
|
||||
parse_mode="html",
|
||||
disable_web_page_preview=not self.web_page,
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
elif self.media:
|
||||
caption = self.caption.html if self.caption and not remove_caption else ""
|
||||
@@ -2698,7 +2704,8 @@ class Message(Object, Update):
|
||||
send_media = partial(
|
||||
self._client.send_cached_media,
|
||||
chat_id=chat_id,
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
|
||||
if self.photo:
|
||||
@@ -2732,14 +2739,16 @@ class Message(Object, Update):
|
||||
first_name=self.contact.first_name,
|
||||
last_name=self.contact.last_name,
|
||||
vcard=self.contact.vcard,
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
elif self.location:
|
||||
return await self._client.send_location(
|
||||
chat_id,
|
||||
latitude=self.location.latitude,
|
||||
longitude=self.location.longitude,
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
elif self.venue:
|
||||
return await self._client.send_venue(
|
||||
@@ -2750,14 +2759,16 @@ class Message(Object, Update):
|
||||
address=self.venue.address,
|
||||
foursquare_id=self.venue.foursquare_id,
|
||||
foursquare_type=self.venue.foursquare_type,
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
elif self.poll:
|
||||
return await self._client.send_poll(
|
||||
chat_id,
|
||||
question=self.poll.question,
|
||||
options=[opt.text for opt in self.poll.options],
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
elif self.game:
|
||||
return await self._client.send_game(
|
||||
@@ -2779,7 +2790,8 @@ class Message(Object, Update):
|
||||
chat_id=chat_id,
|
||||
from_chat_id=self.chat.id,
|
||||
message_ids=self.message_id,
|
||||
disable_notification=disable_notification
|
||||
disable_notification=disable_notification,
|
||||
schedule_date=schedule_date
|
||||
)
|
||||
|
||||
async def delete(self, revoke: bool = True):
|
||||
|
@@ -42,15 +42,15 @@ class Photo(Object):
|
||||
height (``int``):
|
||||
Photo height.
|
||||
|
||||
ttl_seconds (``int``):
|
||||
Time-to-live seconds, for secret photos.
|
||||
|
||||
file_size (``int``):
|
||||
File size.
|
||||
|
||||
date (``int``):
|
||||
Date the photo was sent in Unix time.
|
||||
|
||||
ttl_seconds (``int``, *optional*):
|
||||
Time-to-live seconds, for secret photos.
|
||||
|
||||
thumbs (List of :obj:`Thumbnail`, *optional*):
|
||||
Available thumbnails of this photo.
|
||||
"""
|
||||
@@ -63,10 +63,10 @@ class Photo(Object):
|
||||
file_ref: str,
|
||||
width: int,
|
||||
height: int,
|
||||
ttl_seconds: int,
|
||||
file_size: int,
|
||||
date: int,
|
||||
thumbs: List[Thumbnail]
|
||||
ttl_seconds: int = None,
|
||||
thumbs: List[Thumbnail] = None
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
@@ -74,9 +74,9 @@ class Photo(Object):
|
||||
self.file_ref = file_ref
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.ttl_seconds = ttl_seconds
|
||||
self.file_size = file_size
|
||||
self.date = date
|
||||
self.ttl_seconds = ttl_seconds
|
||||
self.thumbs = thumbs
|
||||
|
||||
@staticmethod
|
||||
@@ -96,9 +96,9 @@ class Photo(Object):
|
||||
file_ref=encode_file_ref(photo.file_reference),
|
||||
width=big.w,
|
||||
height=big.h,
|
||||
ttl_seconds=ttl_seconds,
|
||||
file_size=big.size,
|
||||
date=photo.date,
|
||||
ttl_seconds=ttl_seconds,
|
||||
thumbs=Thumbnail._parse(client, photo),
|
||||
client=client
|
||||
)
|
||||
|
@@ -60,6 +60,9 @@ class Video(Object):
|
||||
date (``int``, *optional*):
|
||||
Date the video was sent in Unix time.
|
||||
|
||||
ttl_seconds (``int``. *optional*):
|
||||
Time-to-live seconds, for secret photos.
|
||||
|
||||
thumbs (List of :obj:`Thumbnail`, *optional*):
|
||||
Video thumbnails.
|
||||
"""
|
||||
@@ -78,6 +81,7 @@ class Video(Object):
|
||||
supports_streaming: bool = None,
|
||||
file_size: int = None,
|
||||
date: int = None,
|
||||
ttl_seconds: int = None,
|
||||
thumbs: List[Thumbnail] = None
|
||||
):
|
||||
super().__init__(client)
|
||||
@@ -92,6 +96,7 @@ class Video(Object):
|
||||
self.supports_streaming = supports_streaming
|
||||
self.file_size = file_size
|
||||
self.date = date
|
||||
self.ttl_seconds = ttl_seconds
|
||||
self.thumbs = thumbs
|
||||
|
||||
@staticmethod
|
||||
@@ -99,7 +104,8 @@ class Video(Object):
|
||||
client,
|
||||
video: types.Document,
|
||||
video_attributes: types.DocumentAttributeVideo,
|
||||
file_name: str
|
||||
file_name: str,
|
||||
ttl_seconds: int = None
|
||||
) -> "Video":
|
||||
return Video(
|
||||
file_id=encode_file_id(
|
||||
@@ -120,6 +126,7 @@ class Video(Object):
|
||||
supports_streaming=video_attributes.supports_streaming,
|
||||
file_size=video.size,
|
||||
date=video.date,
|
||||
ttl_seconds=ttl_seconds,
|
||||
thumbs=Thumbnail._parse(client, video),
|
||||
client=client
|
||||
)
|
||||
|
Reference in New Issue
Block a user