2015-07-09 02:15:46 +02:00
|
|
|
#!/usr/bin/env python
|
2015-08-11 21:58:17 +02:00
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2022-01-03 08:15:18 +01:00
|
|
|
# Copyright (C) 2015-2022
|
2016-01-05 14:12:03 +01:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
2015-08-11 21:58:17 +02:00
|
|
|
#
|
|
|
|
# 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/].
|
2016-10-17 00:22:40 +02:00
|
|
|
"""This module contains an object that represents a Telegram ForceReply."""
|
2015-08-11 21:58:17 +02:00
|
|
|
|
2022-11-22 11:07:42 +01:00
|
|
|
from typing import ClassVar
|
|
|
|
|
|
|
|
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
|
|
|
|
2015-07-09 02:15:46 +02:00
|
|
|
|
2022-01-19 18:00:21 +01:00
|
|
|
class ForceReply(TelegramObject):
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
|
|
|
Upon receiving a message with this object, Telegram clients will display a reply interface to
|
|
|
|
the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be
|
|
|
|
extremely useful if you want to create user-friendly step-by-step interfaces without having
|
|
|
|
to sacrifice privacy mode.
|
2015-08-28 17:19:30 +02:00
|
|
|
|
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:`selective` is equal.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. versionchanged:: 20.0
|
2021-08-29 18:17:06 +02:00
|
|
|
The (undocumented) argument ``force_reply`` was removed and instead :attr:`force_reply`
|
|
|
|
is now always set to :obj:`True` as expected by the Bot API.
|
|
|
|
|
2015-08-28 17:19:30 +02:00
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
selective (:obj:`bool`, optional): Use this parameter if you want to force reply from
|
|
|
|
specific users only. Targets:
|
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
1) Users that are @mentioned in the :attr:`~telegram.Message.text` of the
|
|
|
|
:class:`telegram.Message` object.
|
|
|
|
2) If the bot's message is a reply (has ``reply_to_message_id``), sender of the
|
2017-07-23 22:33:08 +02:00
|
|
|
original message.
|
2016-10-17 00:11:20 +02:00
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
input_field_placeholder (:obj:`str`, optional): The placeholder to be shown in the input
|
2022-11-22 11:07:42 +01:00
|
|
|
field when the reply is active;
|
|
|
|
:tg-const:`telegram.ForceReply.MIN_INPUT_FIELD_PLACEHOLDER`-
|
|
|
|
:tg-const:`telegram.ForceReply.MAX_INPUT_FIELD_PLACEHOLDER`
|
|
|
|
characters.
|
2021-07-01 17:45:19 +02:00
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Attributes:
|
|
|
|
force_reply (:obj:`True`): Shows reply interface to the user, as if they manually selected
|
|
|
|
the bots message and tapped 'Reply'.
|
|
|
|
selective (:obj:`bool`): Optional. Force reply from specific users only.
|
2021-07-01 17:45:19 +02:00
|
|
|
input_field_placeholder (:obj:`str`): Optional. The placeholder shown in the input
|
|
|
|
field when the reply is active.
|
|
|
|
|
|
|
|
.. versionadded:: 13.7
|
2020-12-30 15:59:50 +01:00
|
|
|
|
2015-08-28 17:19:30 +02:00
|
|
|
"""
|
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
__slots__ = ("selective", "force_reply", "input_field_placeholder")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2021-07-01 17:45:19 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
2022-05-09 19:30:46 +02:00
|
|
|
selective: bool = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
input_field_placeholder: str = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2021-07-01 17:45:19 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2021-08-29 18:17:06 +02:00
|
|
|
self.force_reply = True
|
2022-05-09 19:30:46 +02:00
|
|
|
self.selective = selective
|
2021-07-01 17:45:19 +02:00
|
|
|
self.input_field_placeholder = input_field_placeholder
|
2020-07-14 21:33:56 +02:00
|
|
|
|
|
|
|
self._id_attrs = (self.selective,)
|
2022-11-22 11:07:42 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
|
|
|
|
2022-11-22 11:07:42 +01:00
|
|
|
MIN_INPUT_FIELD_PLACEHOLDER: ClassVar[int] = constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER
|
|
|
|
""":const:`telegram.constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|
|
|
|
MAX_INPUT_FIELD_PLACEHOLDER: ClassVar[int] = constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER
|
|
|
|
""":const:`telegram.constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER`
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
|
|
|
"""
|