From a7044562aff715dad74f7752675b230785098fa4 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Thu, 25 May 2017 14:13:35 +0200 Subject: [PATCH] Fix stuff as per @tsnoam's comments --- telegram/bot.py | 6 +++--- telegram/inputfile.py | 31 ++++++------------------------- telegram/message.py | 2 +- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/telegram/bot.py b/telegram/bot.py index b1c4211fc..3a56fd876 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -687,9 +687,9 @@ class Bot(TelegramObject): Args: chat_id (int|str): Unique identifier for the message recipient - Chat id. - voice: Video note to send. Pass a file_id as String to send a video note that exists - on the Telegram servers (recommended) or upload a new video. Sending video notes - by a URL is currently unsupported + video_note (InputFile|str): Video note to send. Pass a file_id as String to send a + video note that exists on the Telegram servers (recommended) or upload a new video. + Sending video notes by a URL is currently unsupported duration (Optional[int]): Duration of sent audio in seconds. length (Optional[int]): Video width and height disable_notification (Optional[bool]): Sends the message silently. iOS users will not diff --git a/telegram/inputfile.py b/telegram/inputfile.py index de4aac011..2f19b6d69 100644 --- a/telegram/inputfile.py +++ b/telegram/inputfile.py @@ -46,30 +46,11 @@ class InputFile(object): self.data = data self.boundary = choose_boundary() - if 'audio' in data: - self.input_name = 'audio' - self.input_file = data.pop('audio') - elif 'document' in data: - self.input_name = 'document' - self.input_file = data.pop('document') - elif 'photo' in data: - self.input_name = 'photo' - self.input_file = data.pop('photo') - elif 'sticker' in data: - self.input_name = 'sticker' - self.input_file = data.pop('sticker') - elif 'video' in data: - self.input_name = 'video' - self.input_file = data.pop('video') - elif 'voice' in data: - self.input_name = 'voice' - self.input_file = data.pop('voice') - elif 'certificate' in data: - self.input_name = 'certificate' - self.input_file = data.pop('certificate') - elif 'video_note' in data: - self.input_name = 'video_note' - self.input_file = data.pop('video_note') + for t in FILE_TYPES: + if t in data: + self.input_name = t + self.input_file = data.pop(t) + break else: raise TelegramError('Unknown inputfile type') @@ -121,7 +102,7 @@ class InputFile(object): form_boundary, 'Content-Disposition: form-data; name="%s"' % name, '', str(value) ]) -# Add input_file to upload + # Add input_file to upload form.extend([ form_boundary, 'Content-Disposition: form-data; name="%s"; filename="%s"' % (self.input_name, diff --git a/telegram/message.py b/telegram/message.py index d3e54313c..295535fd5 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -129,7 +129,6 @@ class Message(TelegramObject): sticker=None, video=None, voice=None, - video_note=None, caption=None, contact=None, location=None, @@ -147,6 +146,7 @@ class Message(TelegramObject): pinned_message=None, forward_from_message_id=None, bot=None, + video_note=None, **kwargs): # Required self.message_id = int(message_id)