X Tutup
Skip to content

Commit 578627f

Browse files
committed
Fixed and added some type hints in docstrings
1 parent 257b832 commit 578627f

File tree

1 file changed

+67
-57
lines changed

1 file changed

+67
-57
lines changed

telegram/bot.py

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def send_message(self,
199199
"""Use this method to send text messages.
200200
201201
Args:
202-
chat_id (str): Unique identifier for the target chat or
202+
chat_id (int|str): Unique identifier for the target chat or
203203
username of the target channel (in the format
204204
@channelusername).
205205
text (str): Text of the message to be sent. The current maximum
@@ -247,7 +247,7 @@ def delete_message(self, chat_id, message_id):
247247
"""Use this method to delete messages which were sent not later than 48 hours ago.
248248
249249
Args:
250-
chat_id (str): Unique identifier for the target chat or
250+
chat_id (int|str): Unique identifier for the target chat or
251251
username of the target channel (in the format
252252
@channelusername).
253253
message_id (int): Unique message identifier.
@@ -281,10 +281,10 @@ def forward_message(self,
281281
"""Use this method to forward messages of any kind.
282282
283283
Args:
284-
chat_id: Unique identifier for the message recipient - Chat id.
285-
from_chat_id: Unique identifier for the chat where the original message was sent
286-
- Chat id.
287-
message_id: Unique message identifier.
284+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
285+
from_chat_id (int|str): Unique identifier for the chat where the original message was
286+
sent - Chat id.
287+
message_id (int): Unique message identifier.
288288
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
289289
receive a notification, Android users will receive a notification with no sound.
290290
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
@@ -325,7 +325,7 @@ def send_photo(self,
325325
"""Use this method to send photos.
326326
327327
Args:
328-
chat_id: Unique identifier for the message recipient - Chat id.
328+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
329329
photo: Photo to send. You can either pass a file_id as String to resend a photo that is
330330
already on the Telegram servers, or upload a new photo using multipart/form-data.
331331
caption (Optional[str]): Photo caption (may also be used when resending photos by
@@ -391,7 +391,7 @@ def send_audio(self,
391391
use sendVoice method instead.
392392
393393
Args:
394-
chat_id: Unique identifier for the message recipient - Chat id.
394+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
395395
audio: Audio file to send. You can either pass a file_id as String to resend an audio
396396
that is already on the Telegram servers, or upload a new audio file using
397397
multipart/form-data.
@@ -458,7 +458,7 @@ def send_document(self,
458458
"""Use this method to send general files.
459459
460460
Args:
461-
chat_id: Unique identifier for the message recipient - Chat id.
461+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
462462
document: File to send. You can either pass a file_id as String to resend a file that
463463
is already on the Telegram servers, or upload a new file using multipart/form-data.
464464
filename (Optional[str]): File name that shows in telegram message (it is useful when
@@ -517,7 +517,7 @@ def send_sticker(self,
517517
"""Use this method to send .webp stickers.
518518
519519
Args:
520-
chat_id: Unique identifier for the message recipient - Chat id.
520+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
521521
sticker: Sticker to send. You can either pass a file_id as String to resend a sticker
522522
that is already on the Telegram servers, or upload a new sticker using
523523
multipart/form-data.
@@ -561,7 +561,7 @@ def send_video(self,
561561
videos (other formats may be sent as telegram.Document).
562562
563563
Args:
564-
chat_id: Unique identifier for the message recipient - Chat id.
564+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
565565
video: Video to send. You can either pass a file_id as String to resend a video that is
566566
already on the Telegram servers, or upload a new video file using
567567
multipart/form-data.
@@ -624,7 +624,7 @@ def send_voice(self,
624624
changed in the future.
625625
626626
Args:
627-
chat_id: Unique identifier for the message recipient - Chat id.
627+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
628628
voice: Audio file to send. You can either pass a file_id as String to resend an audio
629629
that is already on the Telegram servers, or upload a new audio file using
630630
multipart/form-data.
@@ -683,7 +683,7 @@ def send_location(self,
683683
"""Use this method to send point on the map.
684684
685685
Args:
686-
chat_id: Unique identifier for the message recipient - Chat id.
686+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
687687
latitude (float): Latitude of location.
688688
longitude (float): Longitude of location.
689689
disable_notification (Optional[bool]): Sends the message silently. iOS users will not
@@ -729,8 +729,8 @@ def send_venue(self,
729729
Use this method to send information about a venue.
730730
731731
Args:
732-
chat_id: Unique identifier for the target chat or username of the target channel (in
733-
the format @channelusername).
732+
chat_id (int|str): Unique identifier for the target chat or username of the target
733+
channel (in the format @channelusername).
734734
latitude (float): Latitude of the venue.
735735
longitude (float): Longitude of the venue.
736736
title (str): Name of the venue.
@@ -786,8 +786,8 @@ def send_contact(self,
786786
Use this method to send phone contacts.
787787
788788
Args:
789-
chat_id: Unique identifier for the target chat or username of the target channel (in
790-
the format @channelusername).
789+
chat_id (int|str): Unique identifier for the target chat or username of the target
790+
channel (in the format @channelusername).
791791
phone_number (str): Contact's phone number.
792792
first_name (str): Contact's first name.
793793
last_name (Optional[str]): Contact's last name.
@@ -832,8 +832,8 @@ def send_game(self,
832832
"""Use this method to send a game.
833833
834834
Args:
835-
chat_id: Unique identifier for the target chat or username of the target channel (in
836-
the format @channelusername).
835+
chat_id (int|str): Unique identifier for the target chat or username of the target
836+
channel (in the format @channelusername).
837837
game_short_name (str): Short name of the game, serves as the unique identifier for the
838838
game.
839839
@@ -870,9 +870,9 @@ def send_chat_action(self, chat_id, action, timeout=None, **kwargs):
870870
Telegram clients clear its typing status).
871871
872872
Args:
873-
chat_id: Unique identifier for the message recipient - Chat id.
874-
action: Type of action to broadcast. Choose one, depending on what the user is about to
875-
receive:
873+
chat_id (int|str): Unique identifier for the message recipient - Chat id.
874+
action(:class:`telegram.ChatAction`|str): Type of action to broadcast. Choose one,
875+
depending on what the user is about to receive:
876876
877877
- ChatAction.TYPING for text messages,
878878
- ChatAction.UPLOAD_PHOTO for photos,
@@ -962,7 +962,7 @@ def get_user_profile_photos(self, user_id, offset=None, limit=100, timeout=None,
962962
"""Use this method to get a list of profile pictures for a user.
963963
964964
Args:
965-
user_id: Unique identifier of the target user.
965+
user_id (int): Unique identifier of the target user.
966966
offset (Optional[int]): Sequential number of the first photo to be returned. By
967967
default, all photos are returned.
968968
limit (Optional[int]): Limits the number of photos to be retrieved. Values between
@@ -999,7 +999,7 @@ def get_file(self, file_id, timeout=None, **kwargs):
999999
moment, bots can download files of up to 20MB in size.
10001000
10011001
Args:
1002-
file_id: File identifier to get info about.
1002+
file_id (str): File identifier to get info about.
10031003
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
10041004
from the server (instead of the one specified during creation of the connection
10051005
pool).
@@ -1032,9 +1032,9 @@ def kick_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
10321032
group for this to work.
10331033
10341034
Args:
1035-
chat_id: Unique identifier for the target group or username of the target supergroup
1036-
(in the format @supergroupusername).
1037-
user_id: Unique identifier of the target user.
1035+
chat_id (int|str): Unique identifier for the target group or username of the target
1036+
supergroup (in the format @supergroupusername).
1037+
user_id (int|str): Unique identifier of the target user.
10381038
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
10391039
from the server (instead of the one specified during creation of the connection
10401040
pool).
@@ -1062,9 +1062,9 @@ def unban_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
10621062
etc. The bot must be an administrator in the group for this to work.
10631063
10641064
Args:
1065-
chat_id: Unique identifier for the target group or username of the target supergroup
1066-
(in the format @supergroupusername).
1067-
user_id: Unique identifier of the target user.
1065+
chat_id (int|str): Unique identifier for the target group or username of the target
1066+
supergroup (in the format @supergroupusername).
1067+
user_id (int|str): Unique identifier of the target user.
10681068
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
10691069
from the server (instead of the one specified during creation of the connection
10701070
pool).
@@ -1152,17 +1152,18 @@ def edit_message_text(self,
11521152
"""Use this method to edit text messages sent by the bot or via the bot (for inline bots).
11531153
11541154
Args:
1155-
text: New text of the message.
1156-
chat_id: Required if inline_message_id is not specified. Unique identifier for the
1157-
target chat or username of the target channel (in the format @channelusername).
1158-
message_id: Required if inline_message_id is not specified. Unique identifier of the
1159-
sent message.
1160-
inline_message_id: Required if chat_id and message_id are not specified. Identifier of
1161-
the inline message.
1162-
parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic,
1163-
fixed-width text or inline URLs in your bot's message.
1164-
disable_web_page_preview: Disables link previews for links in this message.
1165-
reply_markup: A JSON-serialized object for an inline keyboard.
1155+
text (str): New text of the message.
1156+
chat_id (Optional[int|str]): Required if inline_message_id is not specified. Unique
1157+
identifier for the target chat or username of the target channel (in the format
1158+
@channelusername).
1159+
message_id (Optional[int]): Required if inline_message_id is not specified. Unique
1160+
identifier of the sent message.
1161+
inline_message_id (Optional[str]): Required if chat_id and message_id are not
1162+
specified. Identifier of the inline message.
1163+
parse_mode (:class:`telegram.ParseMode`|str): Send Markdown or HTML, if you want
1164+
Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's
1165+
message.
1166+
disable_web_page_preview (bool): Disables link previews for links in this message.
11661167
reply_markup (Optional[:class:`telegram.ReplyMarkup`]): Additional interface options. A
11671168
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
11681169
to remove reply keyboard or to force a reply from the user.
@@ -1210,10 +1211,10 @@ def edit_message_caption(self,
12101211
bots).
12111212
12121213
Args:
1213-
chat_id (Optional[str]): Required if inline_message_id is not specified. Unique
1214+
chat_id (Optional[int|str]): Required if inline_message_id is not specified. Unique
12141215
identifier for the target chat or username of the target channel (in the format
12151216
@channelusername).
1216-
message_id (Optional[str]): Required if inline_message_id is not specified. Unique
1217+
message_id (Optional[int]): Required if inline_message_id is not specified. Unique
12171218
identifier of the sent message.
12181219
inline_message_id (Optional[str]): Required if chat_id and message_id are not
12191220
specified. Identifier of the inline message.
@@ -1266,10 +1267,10 @@ def edit_message_reply_markup(self,
12661267
(for inline bots).
12671268
12681269
Args:
1269-
chat_id (Optional[str]): Required if inline_message_id is not specified. Unique
1270+
chat_id (Optional[int|str]): Required if inline_message_id is not specified. Unique
12701271
identifier for the target chat or username of the target channel (in the format
12711272
@channelusername).
1272-
message_id (Optional[str]): Required if inline_message_id is not specified. Unique
1273+
message_id (Optional[int]): Required if inline_message_id is not specified. Unique
12731274
identifier of the sent message.
12741275
inline_message_id (Optional[str]): Required if chat_id and message_id are not
12751276
specified. Identifier of the inline message.
@@ -1404,7 +1405,8 @@ def set_webhook(self,
14041405
will give up after a reasonable amount of attempts.
14051406
14061407
Args:
1407-
url: HTTPS url to send updates to. Use an empty string to remove webhook integration.
1408+
url (str): HTTPS url to send updates to. Use an empty string to remove webhook
1409+
integration.
14081410
certificate (file): Upload your public key certificate so that the root certificate in
14091411
use can be checked.
14101412
max_connections (Optional[int]): Maximum allowed number of simultaneous HTTPS
@@ -1489,8 +1491,8 @@ def leave_chat(self, chat_id, timeout=None, **kwargs):
14891491
"""Use this method for your bot to leave a group, supergroup or channel.
14901492
14911493
Args:
1492-
chat_id: Unique identifier for the target chat or username of the target channel (in
1493-
the format @channelusername).
1494+
chat_id (int|str): Unique identifier for the target chat or username of the target
1495+
channel (in the format @channelusername).
14941496
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
14951497
from the server (instead of the one specified during creation of the connection
14961498
pool).
@@ -1517,8 +1519,8 @@ def get_chat(self, chat_id, timeout=None, **kwargs):
15171519
for one-on-one conversations, current username of a user, group or channel, etc.).
15181520
15191521
Args:
1520-
chat_id: Unique identifier for the target chat or username of the target channel (in
1521-
the format @channelusername).
1522+
chat_id (int|str): Unique identifier for the target chat or username of the target
1523+
channel (in the format @channelusername).
15221524
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
15231525
from the server (instead of the one specified during creation of the connection
15241526
pool).
@@ -1548,8 +1550,8 @@ def get_chat_administrators(self, chat_id, timeout=None, **kwargs):
15481550
creator will be returned.
15491551
15501552
Args:
1551-
chat_id: Unique identifier for the target chat or username of the target channel (in
1552-
the format @channelusername).
1553+
chat_id (int|str): Unique identifier for the target chat or username of the target
1554+
channel (in the format @channelusername).
15531555
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
15541556
from the server (instead of the one specified during creation of the connection
15551557
pool).
@@ -1575,8 +1577,8 @@ def get_chat_members_count(self, chat_id, timeout=None, **kwargs):
15751577
"""Use this method to get the number of members in a chat.
15761578
15771579
Args:
1578-
chat_id: Unique identifier for the target chat or username of the target channel (in
1579-
the format @channelusername).
1580+
chat_id (int|str): Unique identifier for the target chat or username of the target
1581+
channel (in the format @channelusername).
15801582
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
15811583
from the server (instead of the one specified during creation of the connection
15821584
pool).
@@ -1602,9 +1604,9 @@ def get_chat_member(self, chat_id, user_id, timeout=None, **kwargs):
16021604
"""Use this method to get information about a member of a chat.
16031605
16041606
Args:
1605-
chat_id: Unique identifier for the target chat or username of the target channel (in
1606-
the format @channelusername).
1607-
user_id: Unique identifier of the target user.
1607+
chat_id (int|str): Unique identifier for the target chat or username of the target
1608+
channel (in the format @channelusername).
1609+
user_id (int): Unique identifier of the target user.
16081610
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
16091611
from the server (instead of the one specified during creation of the connection
16101612
pool).
@@ -1722,6 +1724,14 @@ def get_game_high_scores(self,
17221724
"""Use this method to get data for high score tables.
17231725
17241726
Args:
1727+
user_id (int): User identifier.
1728+
chat_id (Optional[int|str]): Required if `inline_message_id` is not specified. Unique
1729+
identifier for the target chat (or username of the target channel in the format
1730+
`@channelusername`)
1731+
message_id (Optional[int]): Required if inline_message_id is not specified. Identifier
1732+
of the sent message.
1733+
inline_message_id (Optional[str]): Required if chat_id and message_id are not
1734+
specified. Identifier of the inline message.
17251735
timeout (Optional[int|float]): If this value is specified, use it as the read timeout
17261736
from the server (instead of the one specified during creation of the connection
17271737
pool).

0 commit comments

Comments
 (0)
X Tutup