mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-11 04:21:29 +01:00
Fixed and added some type hints in docstrings
This commit is contained in:
parent
257b8321f8
commit
578627feca
1 changed files with 67 additions and 57 deletions
124
telegram/bot.py
124
telegram/bot.py
|
@ -199,7 +199,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to send text messages.
|
"""Use this method to send text messages.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id (str): Unique identifier for the target chat or
|
chat_id (int|str): Unique identifier for the target chat or
|
||||||
username of the target channel (in the format
|
username of the target channel (in the format
|
||||||
@channelusername).
|
@channelusername).
|
||||||
text (str): Text of the message to be sent. The current maximum
|
text (str): Text of the message to be sent. The current maximum
|
||||||
|
@ -247,7 +247,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to delete messages which were sent not later than 48 hours ago.
|
"""Use this method to delete messages which were sent not later than 48 hours ago.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id (str): Unique identifier for the target chat or
|
chat_id (int|str): Unique identifier for the target chat or
|
||||||
username of the target channel (in the format
|
username of the target channel (in the format
|
||||||
@channelusername).
|
@channelusername).
|
||||||
message_id (int): Unique message identifier.
|
message_id (int): Unique message identifier.
|
||||||
|
@ -281,10 +281,10 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to forward messages of any kind.
|
"""Use this method to forward messages of any kind.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
from_chat_id: Unique identifier for the chat where the original message was sent
|
from_chat_id (int|str): Unique identifier for the chat where the original message was
|
||||||
- Chat id.
|
sent - Chat id.
|
||||||
message_id: Unique message identifier.
|
message_id (int): Unique message identifier.
|
||||||
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
|
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
|
||||||
receive a notification, Android users will receive a notification with no sound.
|
receive a notification, Android users will receive a notification with no sound.
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
|
@ -325,7 +325,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to send photos.
|
"""Use this method to send photos.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
photo: Photo to send. You can either pass a file_id as String to resend a photo that is
|
photo: Photo to send. You can either pass a file_id as String to resend a photo that is
|
||||||
already on the Telegram servers, or upload a new photo using multipart/form-data.
|
already on the Telegram servers, or upload a new photo using multipart/form-data.
|
||||||
caption (Optional[str]): Photo caption (may also be used when resending photos by
|
caption (Optional[str]): Photo caption (may also be used when resending photos by
|
||||||
|
@ -391,7 +391,7 @@ class Bot(TelegramObject):
|
||||||
use sendVoice method instead.
|
use sendVoice method instead.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
audio: Audio file to send. You can either pass a file_id as String to resend an audio
|
audio: Audio file to send. You can either pass a file_id as String to resend an audio
|
||||||
that is already on the Telegram servers, or upload a new audio file using
|
that is already on the Telegram servers, or upload a new audio file using
|
||||||
multipart/form-data.
|
multipart/form-data.
|
||||||
|
@ -458,7 +458,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to send general files.
|
"""Use this method to send general files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
document: File to send. You can either pass a file_id as String to resend a file that
|
document: File to send. You can either pass a file_id as String to resend a file that
|
||||||
is already on the Telegram servers, or upload a new file using multipart/form-data.
|
is already on the Telegram servers, or upload a new file using multipart/form-data.
|
||||||
filename (Optional[str]): File name that shows in telegram message (it is useful when
|
filename (Optional[str]): File name that shows in telegram message (it is useful when
|
||||||
|
@ -517,7 +517,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to send .webp stickers.
|
"""Use this method to send .webp stickers.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
sticker: Sticker to send. You can either pass a file_id as String to resend a sticker
|
sticker: Sticker to send. You can either pass a file_id as String to resend a sticker
|
||||||
that is already on the Telegram servers, or upload a new sticker using
|
that is already on the Telegram servers, or upload a new sticker using
|
||||||
multipart/form-data.
|
multipart/form-data.
|
||||||
|
@ -561,7 +561,7 @@ class Bot(TelegramObject):
|
||||||
videos (other formats may be sent as telegram.Document).
|
videos (other formats may be sent as telegram.Document).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
video: Video to send. You can either pass a file_id as String to resend a video that is
|
video: Video to send. You can either pass a file_id as String to resend a video that is
|
||||||
already on the Telegram servers, or upload a new video file using
|
already on the Telegram servers, or upload a new video file using
|
||||||
multipart/form-data.
|
multipart/form-data.
|
||||||
|
@ -624,7 +624,7 @@ class Bot(TelegramObject):
|
||||||
changed in the future.
|
changed in the future.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
voice: Audio file to send. You can either pass a file_id as String to resend an audio
|
voice: Audio file to send. You can either pass a file_id as String to resend an audio
|
||||||
that is already on the Telegram servers, or upload a new audio file using
|
that is already on the Telegram servers, or upload a new audio file using
|
||||||
multipart/form-data.
|
multipart/form-data.
|
||||||
|
@ -683,7 +683,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to send point on the map.
|
"""Use this method to send point on the map.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
latitude (float): Latitude of location.
|
latitude (float): Latitude of location.
|
||||||
longitude (float): Longitude of location.
|
longitude (float): Longitude of location.
|
||||||
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
|
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
|
||||||
|
@ -729,8 +729,8 @@ class Bot(TelegramObject):
|
||||||
Use this method to send information about a venue.
|
Use this method to send information about a venue.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
latitude (float): Latitude of the venue.
|
latitude (float): Latitude of the venue.
|
||||||
longitude (float): Longitude of the venue.
|
longitude (float): Longitude of the venue.
|
||||||
title (str): Name of the venue.
|
title (str): Name of the venue.
|
||||||
|
@ -786,8 +786,8 @@ class Bot(TelegramObject):
|
||||||
Use this method to send phone contacts.
|
Use this method to send phone contacts.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
phone_number (str): Contact's phone number.
|
phone_number (str): Contact's phone number.
|
||||||
first_name (str): Contact's first name.
|
first_name (str): Contact's first name.
|
||||||
last_name (Optional[str]): Contact's last name.
|
last_name (Optional[str]): Contact's last name.
|
||||||
|
@ -832,8 +832,8 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to send a game.
|
"""Use this method to send a game.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
game_short_name (str): Short name of the game, serves as the unique identifier for the
|
game_short_name (str): Short name of the game, serves as the unique identifier for the
|
||||||
game.
|
game.
|
||||||
|
|
||||||
|
@ -870,9 +870,9 @@ class Bot(TelegramObject):
|
||||||
Telegram clients clear its typing status).
|
Telegram clients clear its typing status).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the message recipient - Chat id.
|
chat_id (int|str): Unique identifier for the message recipient - Chat id.
|
||||||
action: Type of action to broadcast. Choose one, depending on what the user is about to
|
action(:class:`telegram.ChatAction`|str): Type of action to broadcast. Choose one,
|
||||||
receive:
|
depending on what the user is about to receive:
|
||||||
|
|
||||||
- ChatAction.TYPING for text messages,
|
- ChatAction.TYPING for text messages,
|
||||||
- ChatAction.UPLOAD_PHOTO for photos,
|
- ChatAction.UPLOAD_PHOTO for photos,
|
||||||
|
@ -962,7 +962,7 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to get a list of profile pictures for a user.
|
"""Use this method to get a list of profile pictures for a user.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id: Unique identifier of the target user.
|
user_id (int): Unique identifier of the target user.
|
||||||
offset (Optional[int]): Sequential number of the first photo to be returned. By
|
offset (Optional[int]): Sequential number of the first photo to be returned. By
|
||||||
default, all photos are returned.
|
default, all photos are returned.
|
||||||
limit (Optional[int]): Limits the number of photos to be retrieved. Values between
|
limit (Optional[int]): Limits the number of photos to be retrieved. Values between
|
||||||
|
@ -999,7 +999,7 @@ class Bot(TelegramObject):
|
||||||
moment, bots can download files of up to 20MB in size.
|
moment, bots can download files of up to 20MB in size.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
file_id: File identifier to get info about.
|
file_id (str): File identifier to get info about.
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1032,9 +1032,9 @@ class Bot(TelegramObject):
|
||||||
group for this to work.
|
group for this to work.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target group or username of the target supergroup
|
chat_id (int|str): Unique identifier for the target group or username of the target
|
||||||
(in the format @supergroupusername).
|
supergroup (in the format @supergroupusername).
|
||||||
user_id: Unique identifier of the target user.
|
user_id (int|str): Unique identifier of the target user.
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1062,9 +1062,9 @@ class Bot(TelegramObject):
|
||||||
etc. The bot must be an administrator in the group for this to work.
|
etc. The bot must be an administrator in the group for this to work.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target group or username of the target supergroup
|
chat_id (int|str): Unique identifier for the target group or username of the target
|
||||||
(in the format @supergroupusername).
|
supergroup (in the format @supergroupusername).
|
||||||
user_id: Unique identifier of the target user.
|
user_id (int|str): Unique identifier of the target user.
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1152,17 +1152,18 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to edit text messages sent by the bot or via the bot (for inline bots).
|
"""Use this method to edit text messages sent by the bot or via the bot (for inline bots).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: New text of the message.
|
text (str): New text of the message.
|
||||||
chat_id: Required if inline_message_id is not specified. Unique identifier for the
|
chat_id (Optional[int|str]): Required if inline_message_id is not specified. Unique
|
||||||
target chat or username of the target channel (in the format @channelusername).
|
identifier for the target chat or username of the target channel (in the format
|
||||||
message_id: Required if inline_message_id is not specified. Unique identifier of the
|
@channelusername).
|
||||||
sent message.
|
message_id (Optional[int]): Required if inline_message_id is not specified. Unique
|
||||||
inline_message_id: Required if chat_id and message_id are not specified. Identifier of
|
identifier of the sent message.
|
||||||
the inline message.
|
inline_message_id (Optional[str]): Required if chat_id and message_id are not
|
||||||
parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
|
specified. Identifier of the inline message.
|
||||||
fixed-width text or inline URLs in your bot's message.
|
parse_mode (:class:`telegram.ParseMode`|str): Send Markdown or HTML, if you want
|
||||||
disable_web_page_preview: Disables link previews for links in this message.
|
Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's
|
||||||
reply_markup: A JSON-serialized object for an inline keyboard.
|
message.
|
||||||
|
disable_web_page_preview (bool): Disables link previews for links in this message.
|
||||||
reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
|
reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
|
||||||
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
|
||||||
to remove reply keyboard or to force a reply from the user.
|
to remove reply keyboard or to force a reply from the user.
|
||||||
|
@ -1210,10 +1211,10 @@ class Bot(TelegramObject):
|
||||||
bots).
|
bots).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id (Optional[str]): Required if inline_message_id is not specified. Unique
|
chat_id (Optional[int|str]): Required if inline_message_id is not specified. Unique
|
||||||
identifier for the target chat or username of the target channel (in the format
|
identifier for the target chat or username of the target channel (in the format
|
||||||
@channelusername).
|
@channelusername).
|
||||||
message_id (Optional[str]): Required if inline_message_id is not specified. Unique
|
message_id (Optional[int]): Required if inline_message_id is not specified. Unique
|
||||||
identifier of the sent message.
|
identifier of the sent message.
|
||||||
inline_message_id (Optional[str]): Required if chat_id and message_id are not
|
inline_message_id (Optional[str]): Required if chat_id and message_id are not
|
||||||
specified. Identifier of the inline message.
|
specified. Identifier of the inline message.
|
||||||
|
@ -1266,10 +1267,10 @@ class Bot(TelegramObject):
|
||||||
(for inline bots).
|
(for inline bots).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id (Optional[str]): Required if inline_message_id is not specified. Unique
|
chat_id (Optional[int|str]): Required if inline_message_id is not specified. Unique
|
||||||
identifier for the target chat or username of the target channel (in the format
|
identifier for the target chat or username of the target channel (in the format
|
||||||
@channelusername).
|
@channelusername).
|
||||||
message_id (Optional[str]): Required if inline_message_id is not specified. Unique
|
message_id (Optional[int]): Required if inline_message_id is not specified. Unique
|
||||||
identifier of the sent message.
|
identifier of the sent message.
|
||||||
inline_message_id (Optional[str]): Required if chat_id and message_id are not
|
inline_message_id (Optional[str]): Required if chat_id and message_id are not
|
||||||
specified. Identifier of the inline message.
|
specified. Identifier of the inline message.
|
||||||
|
@ -1404,7 +1405,8 @@ class Bot(TelegramObject):
|
||||||
will give up after a reasonable amount of attempts.
|
will give up after a reasonable amount of attempts.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
url: HTTPS url to send updates to. Use an empty string to remove webhook integration.
|
url (str): HTTPS url to send updates to. Use an empty string to remove webhook
|
||||||
|
integration.
|
||||||
certificate (file): Upload your public key certificate so that the root certificate in
|
certificate (file): Upload your public key certificate so that the root certificate in
|
||||||
use can be checked.
|
use can be checked.
|
||||||
max_connections (Optional[int]): Maximum allowed number of simultaneous HTTPS
|
max_connections (Optional[int]): Maximum allowed number of simultaneous HTTPS
|
||||||
|
@ -1489,8 +1491,8 @@ class Bot(TelegramObject):
|
||||||
"""Use this method for your bot to leave a group, supergroup or channel.
|
"""Use this method for your bot to leave a group, supergroup or channel.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1517,8 +1519,8 @@ class Bot(TelegramObject):
|
||||||
for one-on-one conversations, current username of a user, group or channel, etc.).
|
for one-on-one conversations, current username of a user, group or channel, etc.).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1548,8 +1550,8 @@ class Bot(TelegramObject):
|
||||||
creator will be returned.
|
creator will be returned.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1575,8 +1577,8 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to get the number of members in a chat.
|
"""Use this method to get the number of members in a chat.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1602,9 +1604,9 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to get information about a member of a chat.
|
"""Use this method to get information about a member of a chat.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
chat_id: Unique identifier for the target chat or username of the target channel (in
|
chat_id (int|str): Unique identifier for the target chat or username of the target
|
||||||
the format @channelusername).
|
channel (in the format @channelusername).
|
||||||
user_id: Unique identifier of the target user.
|
user_id (int): Unique identifier of the target user.
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
@ -1722,6 +1724,14 @@ class Bot(TelegramObject):
|
||||||
"""Use this method to get data for high score tables.
|
"""Use this method to get data for high score tables.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
user_id (int): User identifier.
|
||||||
|
chat_id (Optional[int|str]): Required if `inline_message_id` is not specified. Unique
|
||||||
|
identifier for the target chat (or username of the target channel in the format
|
||||||
|
`@channelusername`)
|
||||||
|
message_id (Optional[int]): Required if inline_message_id is not specified. Identifier
|
||||||
|
of the sent message.
|
||||||
|
inline_message_id (Optional[str]): Required if chat_id and message_id are not
|
||||||
|
specified. Identifier of the inline message.
|
||||||
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
|
||||||
from the server (instead of the one specified during creation of the connection
|
from the server (instead of the one specified during creation of the connection
|
||||||
pool).
|
pool).
|
||||||
|
|
Loading…
Reference in a new issue