Skip to content

Commit a04c1cd

Browse files
committed
small changes
1 parent f4f4645 commit a04c1cd

30 files changed

+96
-94
lines changed

docs/source/telegram.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ telegram package
55

66
telegram.ext
77
telegram.utils
8+
telegram.animation
89
telegram.audio
910
telegram.bot
1011
telegram.callbackquery
@@ -22,11 +23,11 @@ telegram package
2223
telegram.inlinekeyboardmarkup
2324
telegram.inputfile
2425
telegram.inputmedia
25-
telegram.inputmediaphoto
26-
telegram.inputmediavideo
27-
telegram.inputmediadocument
2826
telegram.inputmediaanimation
2927
telegram.inputmediaaudio
28+
telegram.inputmediadocument
29+
telegram.inputmediaphoto
30+
telegram.inputmediavideo
3031
telegram.keyboardbutton
3132
telegram.location
3233
telegram.message
@@ -109,7 +110,6 @@ Games
109110
.. toctree::
110111

111112
telegram.game
112-
telegram.animation
113113
telegram.callbackgame
114114
telegram.gamehighscore
115115

telegram/bot.py

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class Bot(TelegramObject):
109109
base_file_url (:obj:`str`, optional): Telegram Bot API file URL.
110110
request (:obj:`telegram.utils.request.Request`, optional): Pre initialized
111111
:obj:`telegram.utils.request.Request`.
112-
private_key (:obj:`bytes`): Private key for decryption of telegram passport data.
113-
private_key_password (:obj:`bytes`): Password for above private key.
112+
private_key (:obj:`bytes`, optional): Private key for decryption of telegram passport data.
113+
private_key_password (:obj:`bytes`, optional): Password for above private key.
114114
115115
"""
116116

@@ -131,15 +131,10 @@ def __init__(self, token, base_url=None, base_file_url=None, request=None, priva
131131
self.logger = logging.getLogger(__name__)
132132

133133
if private_key:
134-
if not CRYPTO:
135-
raise ValueError('private_key given, but no crypto library found. Try pip '
136-
'install cryptography before proceeding.')
137-
else:
138-
self.private_key = serialization.load_pem_private_key(
139-
private_key,
140-
password=private_key_password,
141-
backend=default_backend()
142-
)
134+
self.private_key = serialization.load_pem_private_key(private_key,
135+
password=private_key_password,
136+
backend=default_backend()
137+
)
143138

144139
@property
145140
def request(self):
@@ -403,7 +398,7 @@ def send_photo(self,
403398

404399
if isinstance(photo, PhotoSize):
405400
photo = photo.file_id
406-
if InputFile.is_file(photo):
401+
elif InputFile.is_file(photo):
407402
photo = InputFile(photo)
408403

409404
data = {'chat_id': chat_id, 'photo': photo}
@@ -465,7 +460,7 @@ def send_audio(self,
465460
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
466461
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
467462
to remove reply keyboard or to force a reply from the user.
468-
thumb (`filelike object`): Thumbnail of the
463+
thumb (`filelike object`, optional): Thumbnail of the
469464
file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
470465
A thumbnail's width and height should not exceed 90. Ignored if the file is not
471466
is passed as a string or file_id.
@@ -483,7 +478,7 @@ def send_audio(self,
483478

484479
if isinstance(audio, Audio):
485480
audio = audio.file_id
486-
if InputFile.is_file(audio):
481+
elif InputFile.is_file(audio):
487482
audio = InputFile(audio)
488483

489484
data = {'chat_id': chat_id, 'audio': audio}
@@ -547,7 +542,7 @@ def send_document(self,
547542
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
548543
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
549544
to remove reply keyboard or to force a reply from the user.
550-
thumb (`filelike object`): Thumbnail of the
545+
thumb (`filelike object`, optional): Thumbnail of the
551546
file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
552547
A thumbnail's width and height should not exceed 90. Ignored if the file is not
553548
is passed as a string or file_id.
@@ -565,7 +560,7 @@ def send_document(self,
565560

566561
if isinstance(document, Document):
567562
document = document.file_id
568-
if InputFile.is_file(document):
563+
elif InputFile.is_file(document):
569564
document = InputFile(document, filename=filename)
570565

571566
data = {'chat_id': chat_id, 'document': document}
@@ -626,7 +621,7 @@ def send_sticker(self,
626621

627622
if isinstance(sticker, Sticker):
628623
sticker = sticker.file_id
629-
if InputFile.is_file(sticker):
624+
elif InputFile.is_file(sticker):
630625
sticker = InputFile(sticker)
631626

632627
data = {'chat_id': chat_id, 'sticker': sticker}
@@ -683,7 +678,7 @@ def send_video(self,
683678
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
684679
JSON-serialized object for an inline keyboard, custom reply keyboard, instructions
685680
to remove reply keyboard or to force a reply from the user.
686-
thumb (`filelike object`): Thumbnail of the
681+
thumb (`filelike object`, optional): Thumbnail of the
687682
file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
688683
A thumbnail's width and height should not exceed 90. Ignored if the file is not
689684
is passed as a string or file_id.
@@ -701,7 +696,7 @@ def send_video(self,
701696

702697
if isinstance(video, Video):
703698
video = video.file_id
704-
if InputFile.is_file(video):
699+
elif InputFile.is_file(video):
705700
video = InputFile(video)
706701

707702
data = {'chat_id': chat_id, 'video': video}
@@ -761,7 +756,7 @@ def send_video_note(self,
761756
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options. A
762757
JSON-serialized object for an inline keyboard, custom reply keyboard,
763758
instructions to remove reply keyboard or to force a reply from the user.
764-
thumb (`filelike object`): Thumbnail of the
759+
thumb (`filelike object`, optional): Thumbnail of the
765760
file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
766761
A thumbnail's width and height should not exceed 90. Ignored if the file is not
767762
is passed as a string or file_id.
@@ -779,7 +774,7 @@ def send_video_note(self,
779774

780775
if isinstance(video_note, VideoNote):
781776
video_note = video_note.file_id
782-
if InputFile.is_file(video_note):
777+
elif InputFile.is_file(video_note):
783778
video_note = InputFile(video_note)
784779

785780
data = {'chat_id': chat_id, 'video_note': video_note}
@@ -825,7 +820,7 @@ def send_animation(self,
825820
duration (:obj:`int`, optional): Duration of sent animation in seconds.
826821
width (:obj:`int`, optional): Animation width.
827822
height (:obj:`int`, optional): Animation height.
828-
thumb (`filelike object`): Thumbnail of the
823+
thumb (`filelike object`, optional): Thumbnail of the
829824
file sent. The thumbnail should be in JPEG format and less than 200 kB in size.
830825
A thumbnail's width and height should not exceed 90. Ignored if the file is not
831826
is passed as a string or file_id.
@@ -855,7 +850,7 @@ def send_animation(self,
855850

856851
if isinstance(animation, Animation):
857852
animation = animation.file_id
858-
if InputFile.is_file(animation):
853+
elif InputFile.is_file(animation):
859854
animation = InputFile(animation)
860855

861856
data = {'chat_id': chat_id, 'animation': animation}
@@ -933,7 +928,7 @@ def send_voice(self,
933928

934929
if isinstance(voice, Voice):
935930
voice = voice.file_id
936-
if InputFile.is_file(voice):
931+
elif InputFile.is_file(voice):
937932
voice = InputFile(voice)
938933

939934
data = {'chat_id': chat_id, 'voice': voice}
@@ -3301,9 +3296,8 @@ def set_passport_data_errors(self, user_id, errors, timeout=None, **kwargs):
33013296
33023297
Args:
33033298
user_id (:obj:`int`): User identifier
3304-
errors (List[:class:`PassportElementError`]): If this value is specified, use it as
3305-
the read timeout from the server (instead of the one specified during
3306-
creation of the connection pool).
3299+
errors (List[:class:`PassportElementError`]): A JSON-serialized array describing the
3300+
errors.
33073301
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
33083302
the read timeout from the server (instead of the one specified during
33093303
creation of the connection pool).

telegram/ext/callbackqueryhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CallbackQueryHandler(Handler):
5050
5151
Note:
5252
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
53-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
53+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
5454
either the user or the chat that the update was sent in. For each update from the same user
5555
or in the same chat, it will be the same ``dict``.
5656

telegram/ext/choseninlineresulthandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ChosenInlineResultHandler(Handler):
3939
4040
Note:
4141
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
42-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
42+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
4343
either the user or the chat that the update was sent in. For each update from the same user
4444
or in the same chat, it will be the same ``dict``.
4545

telegram/ext/commandhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CommandHandler(Handler):
5252
5353
Note:
5454
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
55-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
55+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
5656
either the user or the chat that the update was sent in. For each update from the same user
5757
or in the same chat, it will be the same ``dict``.
5858

telegram/ext/dispatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,4 @@ def dispatch_error(self, update, error):
385385

386386
else:
387387
self.logger.exception(
388-
'No error handlers are registered, logging exception...', exc_info=error)
388+
'No error handlers are registered, logging exception.', exc_info=error)

telegram/ext/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Handler(object):
3535
3636
Note:
3737
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
38-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
38+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
3939
either the user or the chat that the update was sent in. For each update from the same user
4040
or in the same chat, it will be the same ``dict``.
4141

telegram/ext/inlinequeryhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class InlineQueryHandler(Handler):
5050
5151
Note:
5252
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
53-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
53+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
5454
either the user or the chat that the update was sent in. For each update from the same user
5555
or in the same chat, it will be the same ``dict``.
5656

telegram/ext/messagehandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class MessageHandler(Handler):
5050
5151
Note:
5252
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
53-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
53+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
5454
either the user or the chat that the update was sent in. For each update from the same user
5555
or in the same chat, it will be the same ``dict``.
5656

telegram/ext/precheckoutqueryhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PreCheckoutQueryHandler(Handler):
3838
3939
Note:
4040
:attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
41-
can use to keep any data in will be sent to the :attr:`callback` function.. Related to
41+
can use to keep any data in will be sent to the :attr:`callback` function. Related to
4242
either the user or the chat that the update was sent in. For each update from the same user
4343
or in the same chat, it will be the same ``dict``.
4444

0 commit comments

Comments
 (0)