|
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# A library that provides a Python interface to the Telegram Bot API |
| 4 | +# Copyright (C) 2015-2016 |
| 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 a object that represents a Telegram WebhookInfo.""" |
| 20 | + |
| 21 | +from telegram import TelegramObject |
| 22 | + |
| 23 | + |
| 24 | +class WebhookInfo(TelegramObject): |
| 25 | + """This object represents a Telegram WebhookInfo. |
| 26 | +
|
| 27 | + Attributes: |
| 28 | + url (str): Webhook URL, may be empty if webhook is not set up |
| 29 | + has_custom_certificate (bool): |
| 30 | + pending_update_count (int): |
| 31 | + last_error_date (Optional[int]): |
| 32 | + last_error_message (Optional[str]): |
| 33 | +
|
| 34 | + Args: |
| 35 | + url (str): Webhook URL, may be empty if webhook is not set up |
| 36 | + has_custom_certificate (bool): |
| 37 | + pending_update_count (int): |
| 38 | + last_error_date (Optional[int]): |
| 39 | + last_error_message (Optional[str]): |
| 40 | + """ |
| 41 | + |
| 42 | + def __init__(self, url, has_custom_certificate, pending_update_count, **kwargs): |
| 43 | + # Required |
| 44 | + self.url = url |
| 45 | + self.has_custom_certificate = has_custom_certificate |
| 46 | + self.pending_update_count = pending_update_count |
| 47 | + self.last_error_date = kwargs.get('last_error_date') |
| 48 | + self.last_error_message = kwargs.get('last_error_message') |
| 49 | + |
| 50 | + @staticmethod |
| 51 | + def de_json(data, bot): |
| 52 | + """ |
| 53 | + Args: |
| 54 | + data (dict): |
| 55 | + bot (telegram.Bot): |
| 56 | +
|
| 57 | + Returns: |
| 58 | + telegram.WebhookInfo: |
| 59 | + """ |
| 60 | + if not data: |
| 61 | + return None |
| 62 | + |
| 63 | + return WebhookInfo(**data) |
0 commit comments