|
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# A library that provides a Python interface to the Telegram Bot API |
| 4 | +# Copyright (C) 2015-2017 |
| 5 | +# Leandro Toledo de Souza <devs@python-telegram-bot.org> |
| 6 | +# |
| 7 | +# This program is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Lesser Public License as published by |
| 9 | +# the Free Software Foundation, either version 3 of the License, or |
| 10 | +# (at your option) any later version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU Lesser Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU Lesser Public License |
| 18 | +# along with this program. If not, see [http://www.gnu.org/licenses/]. |
| 19 | +"""This module contains an object that represents a Telegram VideoNote.""" |
| 20 | + |
| 21 | +from telegram import PhotoSize, TelegramObject |
| 22 | + |
| 23 | + |
| 24 | +class VideoNote(TelegramObject): |
| 25 | + """This object represents a Telegram VideoNote. |
| 26 | +
|
| 27 | + Attributes: |
| 28 | + file_id (str): Unique identifier for this file |
| 29 | + length (int): Video width and height as defined by sender |
| 30 | + duration (int): Duration of the video in seconds as defined by sender |
| 31 | + thumb (Optional[:class:`telegram.PhotoSize`]): Video thumbnail |
| 32 | + file_size (Optional[int]): File size |
| 33 | + """ |
| 34 | + |
| 35 | + def __init__(self, file_id, length, duration, thumb=None, file_size=None, **kwargs): |
| 36 | + # Required |
| 37 | + self.file_id = str(file_id) |
| 38 | + self.length = int(length) |
| 39 | + self.duration = int(duration) |
| 40 | + # Optionals |
| 41 | + self.thumb = thumb |
| 42 | + self.file_size = file_size |
| 43 | + |
| 44 | + self._id_attrs = (self.file_id,) |
| 45 | + |
| 46 | + @staticmethod |
| 47 | + def de_json(data, bot): |
| 48 | + """ |
| 49 | + Args: |
| 50 | + data (dict): |
| 51 | + bot (telegram.Bot): |
| 52 | +
|
| 53 | + Returns: |
| 54 | + telegram.VideoNote: |
| 55 | + """ |
| 56 | + if not data: |
| 57 | + return None |
| 58 | + |
| 59 | + data = super(VideoNote, VideoNote).de_json(data, bot) |
| 60 | + |
| 61 | + data['thumb'] = PhotoSize.de_json(data.get('thumb'), bot) |
| 62 | + |
| 63 | + return VideoNote(**data) |
0 commit comments