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

@@ -119,7 +119,7 @@ def unregister(callback, event=None):
def is_handler(callback):
"""
Returns ``True`` if the given callback is an
Returns `True` if the given callback is an
event handler (i.e. you used `register` on it).
"""
return hasattr(callback, _HANDLERS_ATTRIBUTE)
@@ -135,6 +135,6 @@ def list(callback):
def _get_handlers(callback):
"""
Like ``list`` but returns ``None`` if the callback was never registered.
Like ``list`` but returns `None` if the callback was never registered.
"""
return getattr(callback, _HANDLERS_ATTRIBUTE, None)

View File

@@ -122,7 +122,7 @@ class Album(EventBuilder):
@property
def is_reply(self):
"""
``True`` if the album is a reply to some other message.
`True` if the album is a reply to some other message.
Remember that you can access the ID of the message
this one is replying to through `reply_to_msg_id`,
@@ -147,7 +147,7 @@ class Album(EventBuilder):
async def get_reply_message(self):
"""
The `Message <telethon.tl.custom.message.Message>`
that this album is replying to, or ``None``.
that this album is replying to, or `None`.
The result will be cached after its first use.
"""
@@ -188,7 +188,7 @@ class Album(EventBuilder):
`telethon.client.messages.MessageMethods.edit_message`
with both ``entity`` and ``message`` already set.
Returns ``None`` if the message was incoming,
Returns `None` if the message was incoming,
or the edited `Message` otherwise.
.. note::
@@ -198,7 +198,7 @@ class Album(EventBuilder):
and **will respect** the previous state of the message.
For example, if the message didn't have a link preview,
the edit won't add one by default, and you should force
it by setting it to ``True`` if you want it.
it by setting it to `True` if you want it.
This is generally the most desired and convenient behaviour,
and will work for link previews and message buttons.

View File

@@ -28,7 +28,7 @@ class CallbackQuery(EventBuilder):
pattern (`bytes`, `str`, `callable`, `Pattern`, optional):
If set, only buttons with payload matching this pattern will be handled.
You can specify a regex-like string which will be matched
against the payload data, a callable function that returns ``True``
against the payload data, a callable function that returns `True`
if a the payload data is acceptable, or a compiled regex pattern.
"""
@@ -210,7 +210,7 @@ class CallbackQuery(EventBuilder):
alert (`bool`, optional):
Whether an alert (a pop-up dialog) should be used
instead of showing a toast. Defaults to ``False``.
instead of showing a toast. Defaults to `False`.
"""
if self._answered:
return
@@ -231,11 +231,11 @@ class CallbackQuery(EventBuilder):
"""
Whether this callback was generated from an inline button sent
via an inline query or not. If the bot sent the message itself
with buttons, and one of those is clicked, this will be ``False``.
with buttons, and one of those is clicked, this will be `False`.
If a user sent the message coming from an inline query to the
bot, and one of those is clicked, this will be ``True``.
bot, and one of those is clicked, this will be `True`.
If it's ``True``, it's likely that the bot is **not** in the
If it's `True`, it's likely that the bot is **not** in the
chat, so methods like `respond` or `delete` won't work (but
`edit` will always work).
"""
@@ -249,7 +249,7 @@ class CallbackQuery(EventBuilder):
This method also creates a task to `answer` the callback.
This method will likely fail if `via_inline` is ``True``.
This method will likely fail if `via_inline` is `True`.
"""
self._client.loop.create_task(self.answer())
return await self._client.send_message(
@@ -263,7 +263,7 @@ class CallbackQuery(EventBuilder):
This method also creates a task to `answer` the callback.
This method will likely fail if `via_inline` is ``True``.
This method will likely fail if `via_inline` is `True`.
"""
self._client.loop.create_task(self.answer())
kwargs['reply_to'] = self.query.msg_id
@@ -276,7 +276,7 @@ class CallbackQuery(EventBuilder):
`telethon.client.messages.MessageMethods.edit_message` with
the ``entity`` set to the correct :tl:`InputBotInlineMessageID`.
Returns ``True`` if the edit was successful.
Returns `True` if the edit was successful.
This method also creates a task to `answer` the callback.
@@ -309,7 +309,7 @@ class CallbackQuery(EventBuilder):
This method also creates a task to `answer` the callback.
This method will likely fail if `via_inline` is ``True``.
This method will likely fail if `via_inline` is `True`.
"""
self._client.loop.create_task(self.answer())
return await self._client.delete_messages(

View File

@@ -83,34 +83,34 @@ class ChatAction(EventBuilder):
The message invoked by this Chat Action.
new_pin (`bool`):
``True`` if there is a new pin.
`True` if there is a new pin.
new_photo (`bool`):
``True`` if there's a new chat photo (or it was removed).
`True` if there's a new chat photo (or it was removed).
photo (:tl:`Photo`, optional):
The new photo (or ``None`` if it was removed).
The new photo (or `None` if it was removed).
user_added (`bool`):
``True`` if the user was added by some other.
`True` if the user was added by some other.
user_joined (`bool`):
``True`` if the user joined on their own.
`True` if the user joined on their own.
user_left (`bool`):
``True`` if the user left on their own.
`True` if the user left on their own.
user_kicked (`bool`):
``True`` if the user was kicked by some other.
`True` if the user was kicked by some other.
created (`bool`, optional):
``True`` if this chat was just created.
`True` if this chat was just created.
new_title (`str`, optional):
The new title string for the chat, if applicable.
unpin (`bool`):
``True`` if the existing pin gets unpinned.
`True` if the existing pin gets unpinned.
"""
def __init__(self, where, new_pin=None, new_photo=None,
added_by=None, kicked_by=None, created=None,
@@ -141,7 +141,7 @@ class ChatAction(EventBuilder):
self.user_added = True
self._added_by = added_by
# If `from_id` was not present (it's ``True``) or the affected
# If `from_id` was not present (it's `True`) or the affected
# user was "kicked by itself", then it left. Else it was kicked.
if kicked_by is True or kicked_by == users:
self.user_left = True
@@ -205,7 +205,7 @@ class ChatAction(EventBuilder):
async def get_pinned_message(self):
"""
If ``new_pin`` is ``True``, this returns the `Message
If ``new_pin`` is `True`, this returns the `Message
<telethon.tl.custom.message.Message>` object that was pinned.
"""
if self._pinned_message == 0:
@@ -231,7 +231,7 @@ class ChatAction(EventBuilder):
@property
def added_by(self):
"""
The user who added ``users``, if applicable (``None`` otherwise).
The user who added ``users``, if applicable (`None` otherwise).
"""
if self._added_by and not isinstance(self._added_by, types.User):
aby = self._entities.get(utils.get_peer_id(self._added_by))
@@ -252,7 +252,7 @@ class ChatAction(EventBuilder):
@property
def kicked_by(self):
"""
The user who kicked ``users``, if applicable (``None`` otherwise).
The user who kicked ``users``, if applicable (`None` otherwise).
"""
if self._kicked_by and not isinstance(self._kicked_by, types.User):
kby = self._entities.get(utils.get_peer_id(self._kicked_by))
@@ -275,7 +275,7 @@ class ChatAction(EventBuilder):
"""
The first user that takes part in this action (e.g. joined).
Might be ``None`` if the information can't be retrieved or
Might be `None` if the information can't be retrieved or
there is no user taking part.
"""
if self.users:

View File

@@ -106,7 +106,7 @@ class EventBuilder(abc.ABC):
def filter(self, event):
"""
If the ID of ``event._chat_peer`` isn't in the chats set (or it is
but the set is a blacklist) returns ``None``, otherwise the event.
but the set is a blacklist) returns `None`, otherwise the event.
The events must have been resolved before this can be called.
"""

View File

@@ -29,7 +29,7 @@ class InlineQuery(EventBuilder):
pattern (`str`, `callable`, `Pattern`, optional):
If set, only queries matching this pattern will be handled.
You can specify a regex-like string which will be matched
against the message, a callable function that returns ``True``
against the message, a callable function that returns `True`
if a message is acceptable, or a compiled regex pattern.
"""
def __init__(

View File

@@ -13,7 +13,7 @@ class MessageEdited(NewMessage):
.. warning::
On channels, `Message.out <telethon.tl.custom.message.Message>`
will be ``True`` if you sent the message originally, **not if
will be `True` if you sent the message originally, **not if
you edited it**! This can be dangerous if you run outgoing
commands on edits.

View File

@@ -10,8 +10,8 @@ class MessageRead(EventBuilder):
Args:
inbox (`bool`, optional):
If this argument is ``True``, then when you read someone else's
messages the event will be fired. By default (``False``) only
If this argument is `True`, then when you read someone else's
messages the event will be fired. By default (`False`) only
when messages you sent are read by someone else will fire it.
"""
def __init__(
@@ -55,10 +55,10 @@ class MessageRead(EventBuilder):
with an ID equal or lower to it have been read.
outbox (`bool`):
``True`` if someone else has read your messages.
`True` if someone else has read your messages.
contents (`bool`):
``True`` if what was read were the contents of a message.
`True` if what was read were the contents of a message.
This will be the case when e.g. you play a voice note.
It may only be set on ``inbox`` events.
"""
@@ -74,7 +74,7 @@ class MessageRead(EventBuilder):
@property
def inbox(self):
"""
``True`` if you have read someone else's messages.
`True` if you have read someone else's messages.
"""
return not self.outbox
@@ -108,7 +108,7 @@ class MessageRead(EventBuilder):
def is_read(self, message):
"""
Returns ``True`` if the given message (or its ID) has been read.
Returns `True` if the given message (or its ID) has been read.
If a list-like argument is provided, this method will return a
list of booleans indicating which messages have been read.
@@ -121,7 +121,7 @@ class MessageRead(EventBuilder):
else message.id) <= self.max_id
def __contains__(self, message):
"""``True`` if the message(s) are read message."""
"""`True` if the message(s) are read message."""
if utils.is_list_like(message):
return all(self.is_read(message))
else:

View File

@@ -12,11 +12,11 @@ class NewMessage(EventBuilder):
Args:
incoming (`bool`, optional):
If set to ``True``, only **incoming** messages will be handled.
If set to `True`, only **incoming** messages will be handled.
Mutually exclusive with ``outgoing`` (can only set one of either).
outgoing (`bool`, optional):
If set to ``True``, only **outgoing** messages will be handled.
If set to `True`, only **outgoing** messages will be handled.
Mutually exclusive with ``incoming`` (can only set one of either).
from_users (`entity`, optional):
@@ -28,14 +28,14 @@ class NewMessage(EventBuilder):
forwards (`bool`, optional):
Whether forwarded messages should be handled or not. By default,
both forwarded and normal messages are included. If it's ``True``
*only* forwards will be handled. If it's ``False`` only messages
both forwarded and normal messages are included. If it's `True`
*only* forwards will be handled. If it's `False` only messages
that are *not* forwards will be handled.
pattern (`str`, `callable`, `Pattern`, optional):
If set, only messages matching this pattern will be handled.
You can specify a regex-like string which will be matched
against the message, a callable function that returns ``True``
against the message, a callable function that returns `True`
if a message is acceptable, or a compiled regex pattern.
"""
def __init__(self, chats=None, *, blacklist_chats=False, func=None,
@@ -181,7 +181,7 @@ class NewMessage(EventBuilder):
>>> @client.on(events.NewMessage(pattern=r'hi (\\w+)!'))
... async def handler(event):
... # In this case, the result is a ``Match`` object
... # since the ``str`` pattern was converted into
... # since the `str` pattern was converted into
... # the ``re.compile(pattern).match`` function.
... print('Welcomed', event.pattern_match.group(1))
...