2023-01-01 17:00:49 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2024-02-19 20:06:25 +01:00
|
|
|
# Copyright (C) 2015-2024
|
2023-01-01 17:00:49 +01:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
|
|
|
"""This module contains objects related to the write access allowed service message."""
|
2023-05-07 13:44:34 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
from telegram._telegramobject import TelegramObject
|
|
|
|
from telegram._utils.types import JSONDict
|
|
|
|
|
|
|
|
|
|
|
|
class WriteAccessAllowed(TelegramObject):
|
|
|
|
"""
|
2023-05-07 13:44:34 +02:00
|
|
|
This object represents a service message about a user allowing a bot to write messages after
|
2023-10-03 14:32:57 +02:00
|
|
|
adding it to the attachment menu, launching a Web App from a link, or accepting an explicit
|
|
|
|
request from a Web App sent by the method
|
|
|
|
`requestWriteAccess <https://core.telegram.org/bots/webapps#initializing-mini-apps>`_.
|
2023-01-01 17:00:49 +01:00
|
|
|
|
2023-10-02 20:21:51 +02:00
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`web_app_name` is equal.
|
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
.. versionadded:: 20.0
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionchanged:: 20.6
|
2023-10-02 20:21:51 +02:00
|
|
|
Added custom equality comparison for objects of this class.
|
2023-05-07 13:44:34 +02:00
|
|
|
|
|
|
|
Args:
|
2023-10-03 14:32:57 +02:00
|
|
|
web_app_name (:obj:`str`, optional): Name of the Web App, if the access was granted when
|
|
|
|
the Web App was launched from a link.
|
2023-05-07 13:44:34 +02:00
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionadded:: 20.3
|
2023-10-03 14:32:57 +02:00
|
|
|
from_request (:obj:`bool`, optional): :obj:`True`, if the access was granted after the user
|
|
|
|
accepted an explicit request from a Web App sent by the method
|
|
|
|
`requestWriteAccess <https://core.telegram.org/bots/webapps#initializing-mini-apps>`_.
|
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2023-10-03 14:32:57 +02:00
|
|
|
from_attachment_menu (:obj:`bool`, optional): :obj:`True`, if the access was granted when
|
|
|
|
the bot was added to the attachment or side menu.
|
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2023-05-07 13:44:34 +02:00
|
|
|
|
|
|
|
Attributes:
|
2023-10-03 14:32:57 +02:00
|
|
|
web_app_name (:obj:`str`): Optional. Name of the Web App, if the access was granted when
|
|
|
|
the Web App was launched from a link.
|
2023-05-07 13:44:34 +02:00
|
|
|
|
2023-05-07 15:31:23 +02:00
|
|
|
.. versionadded:: 20.3
|
2023-10-03 14:32:57 +02:00
|
|
|
from_request (:obj:`bool`): Optional. :obj:`True`, if the access was granted after the user
|
2023-10-03 15:39:57 +02:00
|
|
|
accepted an explicit request from a Web App.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2023-10-03 14:32:57 +02:00
|
|
|
from_attachment_menu (:obj:`bool`): Optional. :obj:`True`, if the access was granted when
|
2023-10-03 15:39:57 +02:00
|
|
|
the bot was added to the attachment or side menu.
|
2023-10-03 14:32:57 +02:00
|
|
|
|
2023-10-03 15:39:57 +02:00
|
|
|
.. versionadded:: 20.6
|
2023-05-07 13:44:34 +02:00
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
"""
|
|
|
|
|
2024-02-05 19:24:00 +01:00
|
|
|
__slots__ = ("from_attachment_menu", "from_request", "web_app_name")
|
2023-01-01 17:00:49 +01:00
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(
|
2023-10-03 14:32:57 +02:00
|
|
|
self,
|
|
|
|
web_app_name: Optional[str] = None,
|
|
|
|
from_request: Optional[bool] = None,
|
|
|
|
from_attachment_menu: Optional[bool] = None,
|
|
|
|
*,
|
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2023-05-18 07:57:59 +02:00
|
|
|
):
|
2023-01-01 17:00:49 +01:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2023-05-07 13:44:34 +02:00
|
|
|
self.web_app_name: Optional[str] = web_app_name
|
2023-10-03 14:32:57 +02:00
|
|
|
self.from_request: Optional[bool] = from_request
|
|
|
|
self.from_attachment_menu: Optional[bool] = from_attachment_menu
|
2023-01-01 17:00:49 +01:00
|
|
|
|
2023-10-02 20:21:51 +02:00
|
|
|
self._id_attrs = (self.web_app_name,)
|
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
self._freeze()
|