Link Python keywords with Python's documentation

This commit is contained in:
Lonami Exo
2019-07-06 12:11:00 +02:00
parent 42d5c0fe6d
commit 8e36bb4c4d
40 changed files with 238 additions and 238 deletions
+17 -17
View File
@@ -131,7 +131,7 @@ class AdminLogEvent:
"""
Whether the channel's about was changed or not.
If ``True``, `old` and `new` will be present as ``str``.
If `True`, `old` and `new` will be present as `str`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionChangeAbout)
@@ -141,7 +141,7 @@ class AdminLogEvent:
"""
Whether the channel's title was changed or not.
If ``True``, `old` and `new` will be present as ``str``.
If `True`, `old` and `new` will be present as `str`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionChangeTitle)
@@ -151,7 +151,7 @@ class AdminLogEvent:
"""
Whether the channel's username was changed or not.
If ``True``, `old` and `new` will be present as ``str``.
If `True`, `old` and `new` will be present as `str`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionChangeUsername)
@@ -161,7 +161,7 @@ class AdminLogEvent:
"""
Whether the channel's photo was changed or not.
If ``True``, `old` and `new` will be present as :tl:`Photo`.
If `True`, `old` and `new` will be present as :tl:`Photo`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionChangePhoto)
@@ -171,7 +171,7 @@ class AdminLogEvent:
"""
Whether the channel's sticker set was changed or not.
If ``True``, `old` and `new` will be present as :tl:`InputStickerSet`.
If `True`, `old` and `new` will be present as :tl:`InputStickerSet`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionChangeStickerSet)
@@ -181,7 +181,7 @@ class AdminLogEvent:
"""
Whether a message in this channel was edited or not.
If ``True``, `old` and `new` will be present as
If `True`, `old` and `new` will be present as
`Message <telethon.tl.custom.message.Message>`.
"""
return isinstance(self.original.action,
@@ -192,7 +192,7 @@ class AdminLogEvent:
"""
Whether a message in this channel was deleted or not.
If ``True``, `old` will be present as
If `True`, `old` will be present as
`Message <telethon.tl.custom.message.Message>`.
"""
return isinstance(self.original.action,
@@ -204,7 +204,7 @@ class AdminLogEvent:
Whether the permissions for an admin in this channel
changed or not.
If ``True``, `old` and `new` will be present as
If `True`, `old` and `new` will be present as
:tl:`ChannelParticipant`.
"""
return isinstance(
@@ -216,7 +216,7 @@ class AdminLogEvent:
"""
Whether a message in this channel was edited or not.
If ``True``, `old` and `new` will be present as
If `True`, `old` and `new` will be present as
:tl:`ChannelParticipant`.
"""
return isinstance(
@@ -228,7 +228,7 @@ class AdminLogEvent:
"""
Whether the invites in the channel were toggled or not.
If ``True``, `old` and `new` will be present as ``bool``.
If `True`, `old` and `new` will be present as `bool`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionToggleInvites)
@@ -238,7 +238,7 @@ class AdminLogEvent:
"""
Whether the location setting of the channel has changed or not.
If ``True``, `old` and `new` will be present as :tl:`ChannelLocation`.
If `True`, `old` and `new` will be present as :tl:`ChannelLocation`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionChangeLocation)
@@ -258,7 +258,7 @@ class AdminLogEvent:
Whether a new user joined through an invite
link to the channel or not.
If ``True``, `new` will be present as
If `True`, `new` will be present as
:tl:`ChannelParticipant`.
"""
return isinstance(self.original.action,
@@ -278,7 +278,7 @@ class AdminLogEvent:
Whether hiding the previous message history for new members
in the channel was toggled or not.
If ``True``, `old` and `new` will be present as ``bool``.
If `True`, `old` and `new` will be present as `bool`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionTogglePreHistoryHidden)
@@ -289,7 +289,7 @@ class AdminLogEvent:
Whether the message signatures in the channel were toggled
or not.
If ``True``, `old` and `new` will be present as ``bool``.
If `True`, `old` and `new` will be present as `bool`.
"""
return isinstance(self.original.action,
types.ChannelAdminLogEventActionToggleSignatures)
@@ -299,7 +299,7 @@ class AdminLogEvent:
"""
Whether a new message in this channel was pinned or not.
If ``True``, `new` will be present as
If `True`, `new` will be present as
`Message <telethon.tl.custom.message.Message>`.
"""
return isinstance(self.original.action,
@@ -310,7 +310,7 @@ class AdminLogEvent:
"""
Whether the default banned rights were changed or not.
If ``True``, `old` and `new` will
If `True`, `old` and `new` will
be present as :tl:`ChatBannedRights`.
"""
return isinstance(self.original.action,
@@ -321,7 +321,7 @@ class AdminLogEvent:
"""
Whether a poll was stopped or not.
If ``True``, `new` will be present as
If `True`, `new` will be present as
`Message <telethon.tl.custom.message.Message>`.
"""
return isinstance(self.original.action,
+2 -2
View File
@@ -43,7 +43,7 @@ class Button:
@staticmethod
def _is_inline(button):
"""
Returns ``True`` if the button belongs to an inline keyboard.
Returns `True` if the button belongs to an inline keyboard.
"""
return isinstance(button, (
types.KeyboardButtonCallback,
@@ -57,7 +57,7 @@ class Button:
Creates a new inline button with some payload data in it.
If `data` is omitted, the given `text` will be used as `data`.
In any case `data` should be either ``bytes`` or ``str``.
In any case `data` should be either `bytes` or `str`.
Note that the given `data` must be less or equal to 64 bytes.
If more than 64 bytes are passed as data, ``ValueError`` is raised.
+5 -5
View File
@@ -21,7 +21,7 @@ class ChatGetter(abc.ABC):
def chat(self):
"""
Returns the :tl:`User`, :tl:`Chat` or :tl:`Channel` where this object
belongs to. It may be ``None`` if Telegram didn't send the chat.
belongs to. It may be `None` if Telegram didn't send the chat.
If you only need the ID, use `chat_id` instead.
@@ -109,9 +109,9 @@ class ChatGetter(abc.ABC):
@property
def is_private(self):
"""
``True`` if the message was sent as a private message.
`True` if the message was sent as a private message.
Returns ``None`` if there isn't enough information
Returns `None` if there isn't enough information
(e.g. on `events.MessageDeleted <telethon.events.messagedeleted.MessageDeleted>`).
"""
return isinstance(self._chat_peer, types.PeerUser) if self._chat_peer else None
@@ -121,7 +121,7 @@ class ChatGetter(abc.ABC):
"""
True if the message was sent on a group or megagroup.
Returns ``None`` if there isn't enough information
Returns `None` if there isn't enough information
(e.g. on `events.MessageDeleted <telethon.events.messagedeleted.MessageDeleted>`).
"""
# TODO Cache could tell us more in the future
@@ -138,7 +138,7 @@ class ChatGetter(abc.ABC):
@property
def is_channel(self):
"""``True`` if the message was sent on a megagroup or channel."""
"""`True` if the message was sent on a megagroup or channel."""
# The only case where chat peer could be none is in MessageDeleted,
# however those always have the peer in channels.
return isinstance(self._chat_peer, types.PeerChannel)
+4 -4
View File
@@ -56,18 +56,18 @@ class Dialog:
this value won't update when new messages arrive.
draft (`Draft <telethon.tl.custom.draft.Draft>`):
The draft object in this dialog. It will not be ``None``,
The draft object in this dialog. It will not be `None`,
so you can call ``draft.set_message(...)``.
is_user (`bool`):
``True`` if the `entity` is a :tl:`User`.
`True` if the `entity` is a :tl:`User`.
is_group (`bool`):
``True`` if the `entity` is a :tl:`Chat`
`True` if the `entity` is a :tl:`Chat`
or a :tl:`Channel` megagroup.
is_channel (`bool`):
``True`` if the `entity` is a :tl:`Channel`.
`True` if the `entity` is a :tl:`Channel`.
"""
def __init__(self, client, dialog, entities, messages):
# Both entities and messages being dicts {ID: item}
+2 -2
View File
@@ -131,7 +131,7 @@ class Draft:
Preserved if left as None.
:param str parse_mode: The parse mode to be used for the text.
:return bool: ``True`` on success.
:return bool: `True` on success.
"""
if text is None:
text = self._text
@@ -175,7 +175,7 @@ class Draft:
async def delete(self):
"""
Deletes this draft, and returns ``True`` on success.
Deletes this draft, and returns `True` on success.
"""
return await self.set_message(text='')
+1 -1
View File
@@ -11,7 +11,7 @@ class File:
supports accessing the attributes in a more convenient way.
If any of the attributes are not present in the current media,
the properties will be ``None``.
the properties will be `None`.
The original media is available through the ``media`` attribute.
"""
+1 -1
View File
@@ -30,7 +30,7 @@ class InlineBuilder:
If present, it must be the contact information to send.
game (`bool`, optional):
May be ``True`` to indicate that the game will be sent.
May be `True` to indicate that the game will be sent.
buttons (`list`, `custom.Button <telethon.tl.custom.button.Button>`, :tl:`KeyboardButton`, optional):
Same as ``buttons`` for `client.send_message()
+4 -4
View File
@@ -54,14 +54,14 @@ class InlineResult:
@property
def title(self):
"""
The title for this inline result. It may be ``None``.
The title for this inline result. It may be `None`.
"""
return self.result.title
@property
def description(self):
"""
The description for this inline result. It may be ``None``.
The description for this inline result. It may be `None`.
"""
return self.result.description
@@ -110,11 +110,11 @@ class InlineResult:
If present, the sent message will reply to this ID or message.
silent (`bool`, optional):
If ``True``, the sent message will not notify the user(s).
If `True`, the sent message will not notify the user(s).
clear_draft (`bool`, optional):
Whether the draft should be removed after sending the
message from this result or not. Defaults to ``False``.
message from this result or not. Defaults to `False`.
hide_via (`bool`, optional):
Whether the "via @bot" should be hidden or not.
+1 -1
View File
@@ -59,7 +59,7 @@ class InlineResults(list):
def results_valid(self):
"""
Returns ``True`` if the cache time has not expired
Returns `True` if the cache time has not expired
yet and the results can still be considered valid.
"""
return time.time() < self._valid_until
+20 -20
View File
@@ -23,14 +23,14 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
Members:
id (`int`):
The ID of this message. This field is *always* present.
Any other member is optional and may be ``None``.
Any other member is optional and may be `None`.
out (`bool`):
Whether the message is outgoing (i.e. you sent it from
another session) or incoming (i.e. someone else sent it).
Note that messages in your own chat are always incoming,
but this member will be ``True`` if you send a message
but this member will be `True` if you send a message
to your own chat. Messages you forward to your chat are
*not* considered outgoing, just like official clients
display them.
@@ -72,15 +72,15 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
message (`str`):
The string text of the message for `Message
<telethon.tl.custom.message.Message>` instances,
which will be ``None`` for other types of messages.
which will be `None` for other types of messages.
action (:tl:`MessageAction`):
The message action object of the message for :tl:`MessageService`
instances, which will be ``None`` for other types of messages.
instances, which will be `None` for other types of messages.
from_id (`int`):
The ID of the user who sent this message. This will be
``None`` if the message was sent in a broadcast channel.
`None` if the message was sent in a broadcast channel.
reply_to_msg_id (`int`):
The ID to which this message is replying to, if any.
@@ -101,7 +101,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
etc. properties instead.
If the media was not present or it was :tl:`MessageMediaEmpty`,
this member will instead be ``None`` for convenience.
this member will instead be `None` for convenience.
reply_markup (:tl:`ReplyMarkup`):
The reply markup for this message (which was sent
@@ -270,7 +270,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
def text(self):
"""
The message text, formatted using the client's default
parse mode. Will be ``None`` for :tl:`MessageService`.
parse mode. Will be `None` for :tl:`MessageService`.
"""
if self._text is None and self._client:
if not self._client.parse_mode:
@@ -293,7 +293,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
def raw_text(self):
"""
The raw message text, ignoring any formatting.
Will be ``None`` for :tl:`MessageService`.
Will be `None` for :tl:`MessageService`.
Setting a value to this field will erase the
`entities`, unlike changing the `message` member.
@@ -309,7 +309,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
@property
def is_reply(self):
"""
``True`` if the message is a reply to some other message.
`True` if the message 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`,
@@ -332,7 +332,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
<telethon.tl.custom.messagebutton.MessageButton>`,
if any.
Otherwise, it returns ``None``.
Otherwise, it returns `None`.
"""
if self._buttons is None and self.reply_markup:
if not self.input_chat:
@@ -384,7 +384,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
"""
Returns a `File <telethon.tl.custom.file.File>` wrapping the
`photo` or `document` in this message. If the media type is different
(polls, games, none, etc.), this property will be ``None``.
(polls, games, none, etc.), this property will be `None`.
This instance lets you easily access other properties, such as
`file.id <telethon.tl.custom.file.File.id>`,
@@ -548,9 +548,9 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
:tl:`MessageActionChatJoinedByLink` :tl:`MessageActionChatMigrateTo`
and :tl:`MessageActionChannelMigrateFrom`.
If the action is neither of those, the result will be ``None``.
If the action is neither of those, the result will be `None`.
If some entities could not be retrieved, the list may contain
some ``None`` items in it.
some `None` items in it.
"""
return self._action_entities
@@ -559,7 +559,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
"""
The bot :tl:`User` if the message was sent via said bot.
This will only be present if `via_bot_id` is not ``None`` and
This will only be present if `via_bot_id` is not `None` and
the entity is known.
"""
return self._via_bot
@@ -581,7 +581,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
(like bold or italics).
The markup entity is a :tl:`MessageEntity` that represents bold,
italics, etc., and the inner text is the ``str`` inside that markup
italics, etc., and the inner text is the `str` inside that markup
entity.
For example:
@@ -617,7 +617,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
async def get_reply_message(self):
"""
The `Message` that this message is replying to, or ``None``.
The `Message` that this message is replying to, or `None`.
The result will be cached after its first use.
"""
@@ -685,7 +685,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
`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::
@@ -695,7 +695,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
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.
@@ -780,7 +780,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
filter (`callable`):
Clicks the first button for which the callable
returns ``True``. The callable should accept a single
returns `True`. The callable should accept a single
`MessageButton <telethon.tl.custom.messagebutton.MessageButton>`
argument.
@@ -929,7 +929,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
This is necessary for :tl:`KeyboardButtonSwitchInline` since we need
to know what bot we want to start. Raises ``ValueError`` if the bot
cannot be found but is needed. Returns ``None`` if it's not needed.
cannot be found but is needed. Returns `None` if it's not needed.
"""
if self._client and not isinstance(self.reply_markup, (
types.ReplyInlineMarkup, types.ReplyKeyboardMarkup)):
+4 -4
View File
@@ -43,19 +43,19 @@ class MessageButton:
@property
def data(self):
"""The ``bytes`` data for :tl:`KeyboardButtonCallback` objects."""
"""The `bytes` data for :tl:`KeyboardButtonCallback` objects."""
if isinstance(self.button, types.KeyboardButtonCallback):
return self.button.data
@property
def inline_query(self):
"""The query ``str`` for :tl:`KeyboardButtonSwitchInline` objects."""
"""The query `str` for :tl:`KeyboardButtonSwitchInline` objects."""
if isinstance(self.button, types.KeyboardButtonSwitchInline):
return self.button.query
@property
def url(self):
"""The url ``str`` for :tl:`KeyboardButtonUrl` objects."""
"""The url `str` for :tl:`KeyboardButtonUrl` objects."""
if isinstance(self.button, types.KeyboardButtonUrl):
return self.button.url
@@ -74,7 +74,7 @@ class MessageButton:
returned.
If it's a :tl:`KeyboardButtonUrl`, the URL of the button will
be passed to ``webbrowser.open`` and return ``True`` on success.
be passed to ``webbrowser.open`` and return `True` on success.
"""
if isinstance(self.button, types.KeyboardButton):
return await self._client.send_message(
+1 -1
View File
@@ -17,7 +17,7 @@ class SenderGetter(abc.ABC):
def sender(self):
"""
Returns the :tl:`User` or :tl:`Channel` that sent this object.
It may be ``None`` if Telegram didn't send the sender.
It may be `None` if Telegram didn't send the sender.
If you only need the ID, use `sender_id` instead.