2020-04-10 19:22:45 +02: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
|
2020-04-10 19:22:45 +02: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 an object that represents a Telegram Bot Command."""
|
|
|
|
|
2023-06-29 18:17:47 +02:00
|
|
|
from typing import Final, Optional
|
2022-11-22 11:07:42 +01:00
|
|
|
|
|
|
|
from telegram import constants
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._telegramobject import TelegramObject
|
2022-10-07 11:51:53 +02:00
|
|
|
from telegram._utils.types import JSONDict
|
2020-10-31 16:33:34 +01:00
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
|
|
|
|
class BotCommand(TelegramObject):
|
|
|
|
"""
|
|
|
|
This object represents a bot command.
|
|
|
|
|
2020-07-14 21:33:56 +02:00
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`command` and :attr:`description` are equal.
|
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
Args:
|
2022-11-22 11:07:42 +01:00
|
|
|
command (:obj:`str`): Text of the command; :tg-const:`telegram.BotCommand.MIN_COMMAND`-
|
|
|
|
:tg-const:`telegram.BotCommand.MAX_COMMAND` characters. Can contain only lowercase
|
2020-04-10 19:22:45 +02:00
|
|
|
English letters, digits and underscores.
|
2022-11-22 11:07:42 +01:00
|
|
|
description (:obj:`str`): Description of the command;
|
|
|
|
:tg-const:`telegram.BotCommand.MIN_DESCRIPTION`-
|
|
|
|
:tg-const:`telegram.BotCommand.MAX_DESCRIPTION` characters.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
|
|
|
Attributes:
|
2023-01-01 16:24:00 +01:00
|
|
|
command (:obj:`str`): Text of the command; :tg-const:`telegram.BotCommand.MIN_COMMAND`-
|
|
|
|
:tg-const:`telegram.BotCommand.MAX_COMMAND` characters. Can contain only lowercase
|
|
|
|
English letters, digits and underscores.
|
|
|
|
description (:obj:`str`): Description of the command;
|
|
|
|
:tg-const:`telegram.BotCommand.MIN_DESCRIPTION`-
|
|
|
|
:tg-const:`telegram.BotCommand.MAX_DESCRIPTION` characters.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
2020-04-10 19:22:45 +02:00
|
|
|
"""
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2024-02-05 19:24:00 +01:00
|
|
|
__slots__ = ("command", "description")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2023-05-18 07:57:59 +02:00
|
|
|
def __init__(self, command: str, description: str, *, api_kwargs: Optional[JSONDict] = None):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.command: str = command
|
|
|
|
self.description: str = description
|
2020-04-10 19:22:45 +02:00
|
|
|
|
2020-07-14 21:33:56 +02:00
|
|
|
self._id_attrs = (self.command, self.description)
|
2022-11-22 11:07:42 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
|
|
|
|
2023-06-29 18:17:47 +02:00
|
|
|
MIN_COMMAND: Final[int] = constants.BotCommandLimit.MIN_COMMAND
|
2022-11-22 11:07:42 +01:00
|
|
|
""":const:`telegram.constants.BotCommandLimit.MIN_COMMAND`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
2023-06-29 18:17:47 +02:00
|
|
|
MAX_COMMAND: Final[int] = constants.BotCommandLimit.MAX_COMMAND
|
2022-11-22 11:07:42 +01:00
|
|
|
""":const:`telegram.constants.BotCommandLimit.MAX_COMMAND`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
2023-06-29 18:17:47 +02:00
|
|
|
MIN_DESCRIPTION: Final[int] = constants.BotCommandLimit.MIN_DESCRIPTION
|
2022-11-22 11:07:42 +01:00
|
|
|
""":const:`telegram.constants.BotCommandLimit.MIN_DESCRIPTION`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
2023-06-29 18:17:47 +02:00
|
|
|
MAX_DESCRIPTION: Final[int] = constants.BotCommandLimit.MAX_DESCRIPTION
|
2022-11-22 11:07:42 +01:00
|
|
|
""":const:`telegram.constants.BotCommandLimit.MAX_DESCRIPTION`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|