mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Make all send_* methods dealing with files aware of StopTransmission
This commit is contained in:
parent
2791600926
commit
4e02cd23a8
@ -45,7 +45,7 @@ class SendAnimation(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound).
|
"""Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -119,6 +119,7 @@ class SendAnimation(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
@ -126,6 +127,7 @@ class SendAnimation(BaseClient):
|
|||||||
file = None
|
file = None
|
||||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(animation):
|
if os.path.exists(animation):
|
||||||
thumb = None if thumb is None else self.save_file(thumb)
|
thumb = None if thumb is None else self.save_file(thumb)
|
||||||
file = self.save_file(animation, progress=progress, progress_args=progress_args)
|
file = self.save_file(animation, progress=progress, progress_args=progress_args)
|
||||||
@ -195,3 +197,5 @@ class SendAnimation(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -45,7 +45,7 @@ class SendAudio(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send audio files.
|
"""Use this method to send audio files.
|
||||||
|
|
||||||
For sending voice messages, use the :obj:`send_voice()` method instead.
|
For sending voice messages, use the :obj:`send_voice()` method instead.
|
||||||
@ -121,6 +121,7 @@ class SendAudio(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
@ -128,6 +129,7 @@ class SendAudio(BaseClient):
|
|||||||
file = None
|
file = None
|
||||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(audio):
|
if os.path.exists(audio):
|
||||||
thumb = None if thumb is None else self.save_file(thumb)
|
thumb = None if thumb is None else self.save_file(thumb)
|
||||||
file = self.save_file(audio, progress=progress, progress_args=progress_args)
|
file = self.save_file(audio, progress=progress, progress_args=progress_args)
|
||||||
@ -195,3 +197,5 @@ class SendAudio(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -42,7 +42,7 @@ class SendDocument(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send general files.
|
"""Use this method to send general files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -107,6 +107,7 @@ class SendDocument(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
@ -114,6 +115,7 @@ class SendDocument(BaseClient):
|
|||||||
file = None
|
file = None
|
||||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(document):
|
if os.path.exists(document):
|
||||||
thumb = None if thumb is None else self.save_file(thumb)
|
thumb = None if thumb is None else self.save_file(thumb)
|
||||||
file = self.save_file(document, progress=progress, progress_args=progress_args)
|
file = self.save_file(document, progress=progress, progress_args=progress_args)
|
||||||
@ -176,3 +178,5 @@ class SendDocument(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -41,7 +41,7 @@ class SendPhoto(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send photos.
|
"""Use this method to send photos.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -105,6 +105,7 @@ class SendPhoto(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
@ -112,6 +113,7 @@ class SendPhoto(BaseClient):
|
|||||||
file = None
|
file = None
|
||||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(photo):
|
if os.path.exists(photo):
|
||||||
file = self.save_file(photo, progress=progress, progress_args=progress_args)
|
file = self.save_file(photo, progress=progress, progress_args=progress_args)
|
||||||
media = types.InputMediaUploadedPhoto(
|
media = types.InputMediaUploadedPhoto(
|
||||||
@ -171,3 +173,5 @@ class SendPhoto(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -38,7 +38,7 @@ class SendSticker(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send .webp stickers.
|
"""Use this method to send .webp stickers.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -89,12 +89,14 @@ class SendSticker(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
"""
|
"""
|
||||||
file = None
|
file = None
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(sticker):
|
if os.path.exists(sticker):
|
||||||
file = self.save_file(sticker, progress=progress, progress_args=progress_args)
|
file = self.save_file(sticker, progress=progress, progress_args=progress_args)
|
||||||
media = types.InputMediaUploadedDocument(
|
media = types.InputMediaUploadedDocument(
|
||||||
@ -155,3 +157,5 @@ class SendSticker(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -46,7 +46,7 @@ class SendVideo(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send video files.
|
"""Use this method to send video files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -123,6 +123,7 @@ class SendVideo(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
@ -130,6 +131,7 @@ class SendVideo(BaseClient):
|
|||||||
file = None
|
file = None
|
||||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(video):
|
if os.path.exists(video):
|
||||||
thumb = None if thumb is None else self.save_file(thumb)
|
thumb = None if thumb is None else self.save_file(thumb)
|
||||||
file = self.save_file(video, progress=progress, progress_args=progress_args)
|
file = self.save_file(video, progress=progress, progress_args=progress_args)
|
||||||
@ -198,3 +200,5 @@ class SendVideo(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -42,7 +42,7 @@ class SendVideoNote(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send video messages.
|
"""Use this method to send video messages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -105,12 +105,14 @@ class SendVideoNote(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
"""
|
"""
|
||||||
file = None
|
file = None
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(video_note):
|
if os.path.exists(video_note):
|
||||||
thumb = None if thumb is None else self.save_file(thumb)
|
thumb = None if thumb is None else self.save_file(thumb)
|
||||||
file = self.save_file(video_note, progress=progress, progress_args=progress_args)
|
file = self.save_file(video_note, progress=progress, progress_args=progress_args)
|
||||||
@ -174,3 +176,5 @@ class SendVideoNote(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
@ -42,7 +42,7 @@ class SendVoice(BaseClient):
|
|||||||
"pyrogram.ReplyKeyboardRemove",
|
"pyrogram.ReplyKeyboardRemove",
|
||||||
"pyrogram.ForceReply"] = None,
|
"pyrogram.ForceReply"] = None,
|
||||||
progress: callable = None,
|
progress: callable = None,
|
||||||
progress_args: tuple = ()) -> "pyrogram.Message":
|
progress_args: tuple = ()) -> Union["pyrogram.Message", None]:
|
||||||
"""Use this method to send audio files.
|
"""Use this method to send audio files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -104,6 +104,7 @@ class SendVoice(BaseClient):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
On success, the sent :obj:`Message <pyrogram.Message>` is returned.
|
||||||
|
In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
@ -111,6 +112,7 @@ class SendVoice(BaseClient):
|
|||||||
file = None
|
file = None
|
||||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||||
|
|
||||||
|
try:
|
||||||
if os.path.exists(voice):
|
if os.path.exists(voice):
|
||||||
file = self.save_file(voice, progress=progress, progress_args=progress_args)
|
file = self.save_file(voice, progress=progress, progress_args=progress_args)
|
||||||
media = types.InputMediaUploadedDocument(
|
media = types.InputMediaUploadedDocument(
|
||||||
@ -174,3 +176,5 @@ class SendVoice(BaseClient):
|
|||||||
{i.id: i for i in r.users},
|
{i.id: i for i in r.users},
|
||||||
{i.id: i for i in r.chats}
|
{i.id: i for i in r.chats}
|
||||||
)
|
)
|
||||||
|
except BaseClient.StopTransmission:
|
||||||
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user