Implemented features from the latest Bot API 3.6.

This commit is contained in:
Alex Root Junior 2018-02-14 14:48:13 +02:00
parent 483c1b295d
commit 819a212b55
4 changed files with 28 additions and 9 deletions

View file

@ -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

View file

@ -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,
@ -380,6 +381,8 @@ 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

View file

@ -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

View file

@ -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()