From 819a212b559d63a2b2fefa52a9f71e82e28db181 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Wed, 14 Feb 2018 14:48:13 +0200 Subject: [PATCH] Implemented features from the latest Bot API 3.6. --- aiogram/__init__.py | 4 ++-- aiogram/bot/bot.py | 9 ++++++--- aiogram/types/input_media.py | 23 +++++++++++++++++++---- aiogram/types/message.py | 1 + 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/aiogram/__init__.py b/aiogram/__init__.py index ddd63c0f..d9d32776 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -20,8 +20,8 @@ else: asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) -VERSION = Version(1, 1, 0, stage=Stage.FINAL, build=0) -API_VERSION = Version(3, 5) +VERSION = Version(1, 1, 1, stage=Stage.DEV, build=0) +API_VERSION = Version(3, 6) __version__ = VERSION.version __api_version__ = API_VERSION.version diff --git a/aiogram/bot/bot.py b/aiogram/bot/bot.py index 86c3d350..8aa3b0fe 100644 --- a/aiogram/bot/bot.py +++ b/aiogram/bot/bot.py @@ -356,6 +356,7 @@ class Bot(BaseBot): width: typing.Union[base.Integer, None] = None, height: typing.Union[base.Integer, None] = None, caption: typing.Union[base.String, None] = None, + supports_streaming: typing.Union[base.Boolean, None] = None, disable_notification: typing.Union[base.Boolean, None] = None, reply_to_message_id: typing.Union[base.Integer, None] = None, reply_markup: typing.Union[types.InlineKeyboardMarkup, @@ -363,8 +364,8 @@ class Bot(BaseBot): types.ReplyKeyboardRemove, types.ForceReply, None] = None) -> types.Message: """ - Use this method to send video files, Telegram clients support mp4 videos - (other formats may be sent as Document). + Use this method to send video files, Telegram clients support mp4 videos + (other formats may be sent as Document). Source: https://core.telegram.org/bots/api#sendvideo @@ -380,12 +381,14 @@ class Bot(BaseBot): :type height: :obj:`typing.Union[base.Integer, None]` :param caption: Video caption (may also be used when resending videos by file_id), 0-200 characters :type caption: :obj:`typing.Union[base.String, None]` + :param supports_streaming: Pass True, if the uploaded video is suitable for streaming + :type supports_streaming: :obj:`typing.Union[base.Boolean, None]` :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`typing.Union[base.Boolean, None]` :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`typing.Union[base.Integer, None]` :param reply_markup: Additional interface options. - :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, + :type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]` :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` diff --git a/aiogram/types/input_media.py b/aiogram/types/input_media.py index e7981462..2ae4da4f 100644 --- a/aiogram/types/input_media.py +++ b/aiogram/types/input_media.py @@ -22,6 +22,15 @@ class InputMedia(base.TelegramObject): type: base.String = fields.Field(default='photo') media: base.String = fields.Field() caption: base.String = fields.Field() + parse_mode: base.Boolean = fields.Field() + + def __init__(self, *args, **kwargs): + super(InputMedia, self).__init__(*args, **kwargs) + try: + if self.parse_mode is None and self.bot.parse_mode: + self.parse_mode = self.bot.parse_mode + except RuntimeError: + pass @property def file(self): @@ -49,8 +58,9 @@ class InputMediaPhoto(InputMedia): https://core.telegram.org/bots/api#inputmediaphoto """ - def __init__(self, media: base.InputFile, caption: base.String = None, **kwargs): - super(InputMediaPhoto, self).__init__(type='photo', media=media, caption=caption, conf=kwargs) + def __init__(self, media: base.InputFile, caption: base.String = None, parse_mode: base.Boolean = None, **kwargs): + super(InputMediaPhoto, self).__init__(type='photo', media=media, caption=caption, parse_mode=parse_mode, + conf=kwargs) if isinstance(media, (io.IOBase, InputFile)): self.file = media @@ -65,11 +75,16 @@ class InputMediaVideo(InputMedia): width: base.Integer = fields.Field() height: base.Integer = fields.Field() duration: base.Integer = fields.Field() + supports_streaming: base.Boolean = fields.Field() def __init__(self, media: base.InputFile, caption: base.String = None, - width: base.Integer = None, height: base.Integer = None, duration: base.Integer = None, **kwargs): + width: base.Integer = None, height: base.Integer = None, duration: base.Integer = None, + parse_mode: base.Boolean = None, + supports_streaming: base.Boolean = None, **kwargs): super(InputMediaVideo, self).__init__(type='video', media=media, caption=caption, - width=width, height=height, duration=duration, conf=kwargs) + width=width, height=height, duration=duration, + parse_mode=parse_mode, + supports_streaming=supports_streaming, conf=kwargs) if isinstance(media, (io.IOBase, InputFile)): self.file = media diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 9ff020f4..1e78598c 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -70,6 +70,7 @@ class Message(base.TelegramObject): pinned_message: 'Message' = fields.Field(base='Message') invoice: Invoice = fields.Field(base=Invoice) successful_payment: SuccessfulPayment = fields.Field(base=SuccessfulPayment) + connected_website: base.String = fields.Field() @property @functools.lru_cache()