From 8884015dae6f6d1304460595d433a701b51257d0 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 10 Mar 2019 13:29:34 +0100 Subject: [PATCH] Clarify some docstrings --- telethon/client/messages.py | 3 ++- telethon/client/uploads.py | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/telethon/client/messages.py b/telethon/client/messages.py index 3389925a..b37d4bbd 100644 --- a/telethon/client/messages.py +++ b/telethon/client/messages.py @@ -612,7 +612,8 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods): from_peer (`entity`): If the given messages are integer IDs and not instances of the ``Message`` class, this *must* be specified in - order for the forward to work. + order for the forward to work. This parameter indicates + the entity from which the messages should be forwarded. silent (`bool`, optional): Whether the message should notify people in a broadcast diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index 583a13d5..b8ffed27 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -95,15 +95,35 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods): Who will receive the file. file (`str` | `bytes` | `file` | `media`): - The path of the file, byte array, or stream that will be sent. - Note that if a byte array or a stream is given, a filename - or its type won't be inferred, and it will be sent as an - "unnamed application/octet-stream". + The file to send, which can be one of: - Furthermore the file may be any media (a message, document, - photo or similar) so that it can be resent without the need - to download and re-upload it again. Bot API ``file_id`` - format is also supported. + * A local file path to an in-disk file. The file name + will be the path's base name. + + * A `bytes` byte array with the file's data to send + (for example, by using ``text.encode('utf-8')``). + A default file name will be used. + + * A bytes `io.IOBase` stream over the file to send + (for example, by using ``open(file, 'rb')``). + Its ``.name`` property will be used for the file name, + or a default if it doesn't have one. + + * An external URL to a file over the internet. This will + send the file as "external" media, and Telegram is the + one that will fetch the media and send it. + + * A Bot API-like ``file_id``. You can convert previously + sent media to file IDs for later reusing with + `telethon.utils.pack_bot_file_id`. + + * A handle to an existing file (for example, if you sent a + message with media before, you can use its ``message.media`` + as a file here). + + * A handle to an uploaded file (from `upload_file`). + + To send an album, you should provide a list in this parameter. If a list or similar is provided, the files in it will be sent as an album in the order in which they appear, sliced