Link Python keywords with Python's documentation

This commit is contained in:
Lonami Exo
2019-07-06 12:10:25 +02:00
parent 42d5c0fe6d
commit 8e36bb4c4d
40 changed files with 238 additions and 238 deletions

View File

@@ -134,8 +134,8 @@ class AccountMethods:
to adjust the `wait_time` of methods like `client.iter_messages
<telethon.client.messages.MessageMethods.iter_messages>`.
By default, all parameters are ``None``, and you need to enable those
you plan to use by setting them to either ``True`` or ``False``.
By default, all parameters are `None`, and you need to enable those
you plan to use by setting them to either `True` or `False`.
You should ``except errors.TakeoutInitDelayError as e``, since this
exception will raise depending on the condition of the session. You
@@ -144,10 +144,10 @@ class AccountMethods:
There's also a `success` property available in the takeout proxy
object, so from the `with` body you can set the boolean result that
will be sent back to Telegram. But if it's left ``None`` as by
will be sent back to Telegram. But if it's left `None` as by
default, then the action is based on the `finalize` parameter. If
it's ``True`` then the takeout will be finished, and if no exception
occurred during it, then ``True`` will be considered as a result.
it's `True` then the takeout will be finished, and if no exception
occurred during it, then `True` will be considered as a result.
Otherwise, the takeout will not be finished and its ID will be
preserved for future usage as `client.session.takeout_id
<telethon.sessions.abstract.Session.takeout_id>`.
@@ -158,26 +158,26 @@ class AccountMethods:
exit or not.
contacts (`bool`):
Set to ``True`` if you plan on downloading contacts.
Set to `True` if you plan on downloading contacts.
users (`bool`):
Set to ``True`` if you plan on downloading information
Set to `True` if you plan on downloading information
from users and their private conversations with you.
chats (`bool`):
Set to ``True`` if you plan on downloading information
Set to `True` if you plan on downloading information
from small group chats, such as messages and media.
megagroups (`bool`):
Set to ``True`` if you plan on downloading information
Set to `True` if you plan on downloading information
from megagroups (channels), such as messages and media.
channels (`bool`):
Set to ``True`` if you plan on downloading information
Set to `True` if you plan on downloading information
from broadcast channels, such as messages and media.
files (`bool`):
Set to ``True`` if you plan on downloading media and
Set to `True` if you plan on downloading media and
you don't only wish to export messages.
max_file_size (`int`):
@@ -228,7 +228,7 @@ class AccountMethods:
Whether the takeout completed successfully or not.
Returns
``True`` if the operation was successful, ``False`` otherwise.
`True` if the operation was successful, `False` otherwise.
Example
.. code-block:: python

View File

@@ -296,7 +296,7 @@ class AuthMethods:
phone_code_hash (`str`, optional):
The hash returned by `send_code_request`. This can be left as
``None`` to use the last hash known for the phone to be used.
`None` to use the last hash known for the phone to be used.
Returns
The signed in user, or the information about
@@ -379,7 +379,7 @@ class AuthMethods:
phone_code_hash (`str`, optional):
The hash returned by `send_code_request`. This can be left as
``None`` to use the last hash known for the phone to be used.
`None` to use the last hash known for the phone to be used.
Returns
The new created :tl:`User`.
@@ -495,7 +495,7 @@ class AuthMethods:
Logs out Telegram and deletes the current ``*.session`` file.
Returns
``True`` if the operation was successful.
`True` if the operation was successful.
Example
.. code-block:: python
@@ -546,7 +546,7 @@ class AuthMethods:
new_password (`str`, optional):
The password to set as 2FA.
If 2FA was already enabled, ``current_password`` **must** be set.
Leaving this blank or ``None`` will remove the password.
Leaving this blank or `None` will remove the password.
hint (`str`, optional):
Hint to be displayed by Telegram when it asks for 2FA.
@@ -567,7 +567,7 @@ class AuthMethods:
``CodeInvalidError``.
Returns
``True`` if successful, ``False`` otherwise.
`True` if successful, `False` otherwise.
Example
.. code-block:: python

View File

@@ -476,9 +476,9 @@ class ChatMethods:
Note that you must be an administrator of it to use this method.
If none of the filters are present (i.e. they all are ``None``),
If none of the filters are present (i.e. they all are `None`),
*all* event types will be returned. If at least one of them is
``True``, only those that are true will be returned.
`True`, only those that are true will be returned.
Arguments
entity (`entity`):
@@ -487,7 +487,7 @@ class ChatMethods:
limit (`int` | `None`, optional):
Number of events to be retrieved.
The limit may also be ``None``, which would eventually return
The limit may also be `None`, which would eventually return
the whole history.
max_id (`int`):
@@ -507,53 +507,53 @@ class ChatMethods:
returned.
join (`bool`):
If ``True``, events for when a user joined will be returned.
If `True`, events for when a user joined will be returned.
leave (`bool`):
If ``True``, events for when a user leaves will be returned.
If `True`, events for when a user leaves will be returned.
invite (`bool`):
If ``True``, events for when a user joins through an invite
If `True`, events for when a user joins through an invite
link will be returned.
restrict (`bool`):
If ``True``, events with partial restrictions will be
If `True`, events with partial restrictions will be
returned. This is what the API calls "ban".
unrestrict (`bool`):
If ``True``, events removing restrictions will be returned.
If `True`, events removing restrictions will be returned.
This is what the API calls "unban".
ban (`bool`):
If ``True``, events applying or removing all restrictions will
If `True`, events applying or removing all restrictions will
be returned. This is what the API calls "kick" (restricting
all permissions removed is a ban, which kicks the user).
unban (`bool`):
If ``True``, events removing all restrictions will be
If `True`, events removing all restrictions will be
returned. This is what the API calls "unkick".
promote (`bool`):
If ``True``, events with admin promotions will be returned.
If `True`, events with admin promotions will be returned.
demote (`bool`):
If ``True``, events with admin demotions will be returned.
If `True`, events with admin demotions will be returned.
info (`bool`):
If ``True``, events changing the group info will be returned.
If `True`, events changing the group info will be returned.
settings (`bool`):
If ``True``, events changing the group settings will be
If `True`, events changing the group settings will be
returned.
pinned (`bool`):
If ``True``, events of new pinned messages will be returned.
If `True`, events of new pinned messages will be returned.
edit (`bool`):
If ``True``, events of message edits will be returned.
If `True`, events of message edits will be returned.
delete (`bool`):
If ``True``, events of message deletions will be returned.
If `True`, events of message deletions will be returned.
Yields
Instances of `AdminLogEvent <telethon.tl.custom.adminlogevent.AdminLogEvent>`.
@@ -626,7 +626,7 @@ class ChatMethods:
limit (`int` | `None`, optional):
Number of photos to be retrieved.
The limit may also be ``None``, which would eventually all
The limit may also be `None`, which would eventually all
the photos that are still available.
offset (`int`):
@@ -725,7 +725,7 @@ class ChatMethods:
auto_cancel (`bool`):
Whether the action should be cancelled once the context
manager exists or not. The default is ``True``, since
manager exists or not. The default is `True`, since
you don't want progress to be shown when it has already
completed.
@@ -905,7 +905,7 @@ class ChatMethods:
user (`entity`, optional):
If specified, the permission will be changed for the specific user.
If left as ``None``, the default chat permissions will be updated.
If left as `None`, the default chat permissions will be updated.
until_date (`DateLike`, optional):
When the user will be unbanned.

View File

@@ -134,7 +134,7 @@ class DialogMethods:
Arguments
limit (`int` | `None`):
How many dialogs to be retrieved as maximum. Can be set to
``None`` to retrieve all dialogs. Note that this may take
`None` to retrieve all dialogs. Note that this may take
whole minutes if you have hundreds of dialogs, as Telegram
will tell the library to slow down through a
``FloodWaitError``.
@@ -150,12 +150,12 @@ class DialogMethods:
ignore_pinned (`bool`, optional):
Whether pinned dialogs should be ignored or not.
When set to ``True``, these won't be yielded at all.
When set to `True`, these won't be yielded at all.
ignore_migrated (`bool`, optional):
Whether :tl:`Chat` that have ``migrated_to`` a :tl:`Channel`
should be included or not. By default all the chats in your
dialogs are returned, but setting this to ``True`` will ignore
dialogs are returned, but setting this to `True` will ignore
(i.e. skip) them in the same way official applications do.
folder (`int`, optional):
@@ -176,7 +176,7 @@ class DialogMethods:
archived (`bool`, optional):
Alias for `folder`. If unspecified, all will be returned,
``False`` implies ``folder=0`` and ``True`` implies ``folder=1``.
`False` implies ``folder=0`` and `True` implies ``folder=1``.
Yields
Instances of `Dialog <telethon.tl.custom.dialog.Dialog>`.
@@ -361,8 +361,8 @@ class DialogMethods:
revoke (`bool`, optional):
On private chats, you may revoke the messages from
the other peer too. By default, it's ``False``. Set
it to ``True`` to delete the history for both.
the other peer too. By default, it's `False`. Set
it to `True` to delete the history for both.
Returns
The :tl:`Updates` object that the request produces,

View File

@@ -125,7 +125,7 @@ class _GenericDownloadIter(_DirectDownloadIter):
self.request.offset = before
# 2. Fill the buffer with the data we have
# 2.1. Slicing ``bytes`` is expensive, yield ``memoryview`` instead
# 2.1. Slicing `bytes` is expensive, yield `memoryview` instead
mem = memoryview(data)
# 2.2. The current chunk starts at ``bad`` offset into the data,
@@ -189,7 +189,7 @@ class DownloadMethods:
Whether to use the big version of the available photos.
Returns
``None`` if no photo was provided, or if it was Empty. On success
`None` if no photo was provided, or if it was Empty. On success
the file path is returned since it may differ from the one given.
Example
@@ -303,7 +303,7 @@ class DownloadMethods:
instead of downloading the document or photo itself.
If it's specified but the file does not have a thumbnail,
this method will return ``None``.
this method will return `None`.
The parameter should be an integer index between ``0`` and
``len(sizes)``. ``0`` will download the smallest thumbnail,
@@ -316,7 +316,7 @@ class DownloadMethods:
and ``thumb=-1`` if you want the largest thumbnail.
Returns
``None`` if no media was provided, or if it was Empty. On success
`None` if no media was provided, or if it was Empty. On success
the file path is returned since it may differ from the one given.
Example
@@ -382,7 +382,7 @@ class DownloadMethods:
The output file path, directory, or stream-like object.
If the path exists and is a file, it will be overwritten.
If the file path is ``None`` or ``bytes``, then the result
If the file path is `None` or `bytes`, then the result
will be saved in memory and returned as `bytes`.
part_size_kb (`int`, optional):
@@ -519,8 +519,8 @@ class DownloadMethods:
Yields
``bytes`` objects representing the chunks of the file if the
right conditions are met, or ``memoryview`` objects instead.
`bytes` objects representing the chunks of the file if the
right conditions are met, or `memoryview` objects instead.
Example
.. code-block:: python

View File

@@ -18,14 +18,14 @@ class MessageParseMethods:
"""
This property is the default parse mode used when sending messages.
Defaults to `telethon.extensions.markdown`. It will always
be either ``None`` or an object with ``parse`` and ``unparse``
be either `None` or an object with ``parse`` and ``unparse``
methods.
When setting a different value it should be one of:
* Object with ``parse`` and ``unparse`` methods.
* A ``callable`` to act as the parse method.
* A ``str`` indicating the ``parse_mode``. For Markdown ``'md'``
* A `str` indicating the ``parse_mode``. For Markdown ``'md'``
or ``'markdown'`` may be used. For HTML, ``'htm'`` or ``'html'``
may be used.

View File

@@ -19,7 +19,7 @@ class _MessagesIter(RequestIter):
self, entity, offset_id, min_id, max_id,
from_user, offset_date, add_offset, filter, search
):
# Note that entity being ``None`` will perform a global search.
# Note that entity being `None` will perform a global search.
if entity:
self.entity = await self.client.get_input_entity(entity)
else:
@@ -331,7 +331,7 @@ class MessageMethods:
entity (`entity`):
The entity from whom to retrieve the message history.
It may be ``None`` to perform a global search, or
It may be `None` to perform a global search, or
to get messages by their ID from no particular chat.
Note that some of the offsets will not work if this
is the case.
@@ -344,7 +344,7 @@ class MessageMethods:
the API retrieving more than 3000 messages will take longer
than half a minute (or even more based on previous calls).
The limit may also be ``None``, which would eventually return
The limit may also be `None`, which would eventually return
the whole history.
offset_date (`datetime`):
@@ -382,7 +382,7 @@ class MessageMethods:
wait_time (`int`):
Wait time (in seconds) between different
:tl:`GetHistoryRequest`. Use this parameter to avoid hitting
the ``FloodWaitError`` as needed. If left to ``None``, it will
the ``FloodWaitError`` as needed. If left to `None`, it will
default to 1 second only if the limit is higher than 3000.
ids (`int`, `list`):
@@ -390,7 +390,7 @@ class MessageMethods:
should be returned. This parameter takes precedence over
the rest (which will be ignored if this is set). This can
for instance be used to get the message with ID 123 from
a channel. Note that if the message doesn't exist, ``None``
a channel. Note that if the message doesn't exist, `None`
will appear in its place, so that zipping the list of IDs
with the messages can match one-to-one.
@@ -404,7 +404,7 @@ class MessageMethods:
careful if you use non-integers in this parameter.
reverse (`bool`, optional):
If set to ``True``, the messages will be returned in reverse
If set to `True`, the messages will be returned in reverse
order (from oldest to newest, instead of the default newest
to oldest). This also means that the meaning of `offset_id`
and `offset_date` parameters is reversed, although they will
@@ -412,7 +412,7 @@ class MessageMethods:
instead of being `max_id` as well since messages are returned
in ascending order.
You cannot use this if both `entity` and `ids` are ``None``.
You cannot use this if both `entity` and `ids` are `None`.
Yields
Instances of `Message <telethon.tl.custom.message.Message>`.
@@ -595,8 +595,8 @@ class MessageMethods:
silent (`bool`, optional):
Whether the message should notify people in a broadcast
channel or not. Defaults to ``False``, which means it will
notify them. Set it to ``True`` to alter this behaviour.
channel or not. Defaults to `False`, which means it will
notify them. Set it to `True` to alter this behaviour.
Returns
The sent `custom.Message <telethon.tl.custom.message.Message>`.
@@ -761,8 +761,8 @@ class MessageMethods:
silent (`bool`, optional):
Whether the message should notify people in a broadcast
channel or not. Defaults to ``False``, which means it will
notify them. Set it to ``True`` to alter this behaviour.
channel or not. Defaults to `False`, which means it will
notify them. Set it to `True` to alter this behaviour.
as_album (`bool`, optional):
Whether several image messages should be forwarded as an
@@ -772,8 +772,8 @@ class MessageMethods:
are used. If IDs are used it will group by default.
In short, the default should do what you expect,
``True`` will group always (even converting separate
images into albums), and ``False`` will never group.
`True` will group always (even converting separate
images into albums), and `False` will never group.
Returns
The list of forwarded `Message <telethon.tl.custom.message.Message>`,
@@ -781,7 +781,7 @@ class MessageMethods:
Note that if all messages are invalid (i.e. deleted) the call
will fail with ``MessageIdInvalidError``. If only some are
invalid, the list will have ``None`` instead of those messages.
invalid, the list will have `None` instead of those messages.
Example
.. code-block:: python
@@ -1003,7 +1003,7 @@ class MessageMethods:
Arguments
entity (`entity`):
From who the message will be deleted. This can actually
be ``None`` for normal chats, but **must** be present
be `None` for normal chats, but **must** be present
for channels and megagroups.
message_ids (`list` | `int` | `Message <telethon.tl.custom.message.Message>`):
@@ -1142,7 +1142,7 @@ class MessageMethods:
message (`int` | `Message <telethon.tl.custom.message.Message>`):
The message or the message ID to pin. If it's
``None``, the message will be unpinned instead.
`None`, the message will be unpinned instead.
notify (`bool`, optional):
Whether the pin should notify people or not.

View File

@@ -39,7 +39,7 @@ class TelegramBaseClient(abc.ABC):
session (`str` | `telethon.sessions.abstract.Session`, `None`):
The file name of the session file to be used if a string is
given (it may be a full path), or the Session instance to be
used otherwise. If it's ``None``, the session will not be saved,
used otherwise. If it's `None`, the session will not be saved,
and you should call :meth:`.log_out()` when you're done.
Note that if you pass a string it will be a file in the current
@@ -64,7 +64,7 @@ class TelegramBaseClient(abc.ABC):
use_ipv6 (`bool`, optional):
Whether to connect to the servers through IPv6 or not.
By default this is ``False`` as IPv6 support is not
By default this is `False` as IPv6 support is not
too widespread yet.
proxy (`tuple` | `list` | `dict`, optional):
@@ -87,14 +87,14 @@ class TelegramBaseClient(abc.ABC):
when there is a ``errors.FloodWaitError`` less than
`flood_sleep_threshold`, or when there's a migrate error.
May take a negative or ``None`` value for infinite retries, but
May take a negative or `None` value for infinite retries, but
this is not recommended, since some requests can always trigger
a call fail (such as searching for messages).
connection_retries (`int` | `None`, optional):
How many times the reconnection should retry, either on the
initial connection or when Telegram disconnects us. May be
set to a negative or ``None`` value for infinite retries, but
set to a negative or `None` value for infinite retries, but
this is not recommended, since the program can get stuck in an
infinite loop.
@@ -111,7 +111,7 @@ class TelegramBaseClient(abc.ABC):
the order in which updates are processed to be sequential, and
this setting allows them to do so.
If set to ``True``, incoming updates will be put in a queue
If set to `True`, incoming updates will be put in a queue
and processed sequentially. This means your event handlers
should *not* perform long-running operations since new
updates are put inside of an unbounded queue.
@@ -423,7 +423,7 @@ class TelegramBaseClient(abc.ABC):
def is_connected(self: 'TelegramClient') -> bool:
"""
Returns ``True`` if the user has connected.
Returns `True` if the user has connected.
This method is **not** asynchronous (don't use ``await`` on it).

View File

@@ -162,7 +162,7 @@ class UploadMethods:
assigned to the files pairwise.
force_document (`bool`, optional):
If left to ``False`` and the file is a path that ends with
If left to `False` and the file is a path that ends with
the extension of an image file or a video file, it will be
sent as such. Otherwise always as a document.
@@ -187,8 +187,8 @@ class UploadMethods:
allow_cache (`bool`, optional):
Whether to allow using the cached version stored in the
database or not. Defaults to ``True`` to avoid re-uploads.
Must be ``False`` if you wish to use different attributes
database or not. Defaults to `True` to avoid re-uploads.
Must be `False` if you wish to use different attributes
or thumb than those that were used when the file was cached.
parse_mode (`object`, optional):
@@ -198,16 +198,16 @@ class UploadMethods:
default.
voice_note (`bool`, optional):
If ``True`` the audio will be sent as a voice note.
If `True` the audio will be sent as a voice note.
Set `allow_cache` to ``False`` if you sent the same file
Set `allow_cache` to `False` if you sent the same file
without this setting before for it to work.
video_note (`bool`, optional):
If ``True`` the video will be sent as a video note,
If `True` the video will be sent as a video note,
also known as a round video message.
Set `allow_cache` to ``False`` if you sent the same file
Set `allow_cache` to `False` if you sent the same file
without this setting before for it to work.
buttons (`list`, `custom.Button <telethon.tl.custom.button.Button>`, :tl:`KeyboardButton`):
@@ -218,8 +218,8 @@ class UploadMethods:
silent (`bool`, optional):
Whether the message should notify people in a broadcast
channel or not. Defaults to ``False``, which means it will
notify them. Set it to ``True`` to alter this behaviour.
channel or not. Defaults to `False`, which means it will
notify them. Set it to `True` to alter this behaviour.
supports_streaming (`bool`, optional):
Whether the sent video supports streaming or not. Note that
@@ -257,7 +257,7 @@ class UploadMethods:
'/my/drawings/portrait.png'
])
"""
# i.e. ``None`` was used
# i.e. `None` was used
if not file:
raise TypeError('Cannot use {!r} as file'.format(file))
@@ -444,7 +444,7 @@ class UploadMethods:
file_name (`str`, optional):
The file name which will be used on the resulting InputFile.
If not specified, the name will be taken from the ``file``
and if this is not a ``str``, it will be ``"unnamed"``.
and if this is not a `str`, it will be ``"unnamed"``.
use_cache (`type`, optional):
The type of cache to use (currently either :tl:`InputDocument`

View File

@@ -105,7 +105,7 @@ class UserMethods:
"""
Gets "me", the current :tl:`User` who is logged in.
If the user has not logged in yet, this method returns ``None``.
If the user has not logged in yet, this method returns `None`.
Arguments
input_peer (`bool`, optional):
@@ -140,7 +140,7 @@ class UserMethods:
async def is_bot(self: 'TelegramClient') -> bool:
"""
Return ``True`` if the signed-in user is a bot, ``False`` otherwise.
Return `True` if the signed-in user is a bot, `False` otherwise.
Example
.. code-block:: python
@@ -157,7 +157,7 @@ class UserMethods:
async def is_user_authorized(self: 'TelegramClient') -> bool:
"""
Returns ``True`` if the user is authorized (i.e. has logged in).
Returns `True` if the user is authorized (i.e. has logged in).
Example
.. code-block:: python