Remove telegram.ReplyMarkup (#2870)

This commit is contained in:
Harshil 2022-01-19 21:00:21 +04:00 committed by Hinrich Mahler
parent 0ccd7d40ac
commit 8560af9c4f
37 changed files with 249 additions and 225 deletions

View file

@ -1,8 +0,0 @@
:github_url: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/replymarkup.py
telegram.ReplyMarkup
====================
.. autoclass:: telegram.ReplyMarkup
:members:
:show-inheritance:

View file

@ -59,7 +59,6 @@ telegram package
telegram.proximityalerttriggered
telegram.replykeyboardremove
telegram.replykeyboardmarkup
telegram.replymarkup
telegram.telegramobject
telegram.update
telegram.user

View file

@ -137,7 +137,6 @@ __all__ = ( # Keep this alphabetically ordered
'ProximityAlertTriggered',
'ReplyKeyboardMarkup',
'ReplyKeyboardRemove',
'ReplyMarkup',
'request',
'ResidentialAddress',
'SecureData',
@ -199,7 +198,6 @@ from ._dice import Dice
from ._userprofilephotos import UserProfilePhotos
from ._keyboardbuttonpolltype import KeyboardButtonPollType
from ._keyboardbutton import KeyboardButton
from ._replymarkup import ReplyMarkup
from ._replykeyboardmarkup import ReplyKeyboardMarkup
from ._replykeyboardremove import ReplyKeyboardRemove
from ._forcereply import ForceReply

View file

@ -75,7 +75,6 @@ from telegram import (
PassportElementError,
PhotoSize,
Poll,
ReplyMarkup,
ShippingOption,
Sticker,
StickerSet,
@ -90,6 +89,9 @@ from telegram import (
WebhookInfo,
InlineKeyboardMarkup,
ChatInviteLink,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
ForceReply,
)
from telegram.error import InvalidToken, TelegramError
from telegram.constants import InlineQueryLimit
@ -97,7 +99,7 @@ from telegram.request import Request
from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue, DEFAULT_20
from telegram._utils.datetime import to_timestamp
from telegram._utils.files import is_local_file, parse_file_input
from telegram._utils.types import FileInput, JSONDict, ODVInput, DVInput
from telegram._utils.types import FileInput, JSONDict, ODVInput, DVInput, ReplyMarkup
if TYPE_CHECKING:
from telegram import (
@ -291,7 +293,8 @@ class Bot(TelegramObject):
data['protect_content'] = protect_content
if reply_markup is not None:
if isinstance(reply_markup, ReplyMarkup):
markups = (InlineKeyboardMarkup, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove)
if isinstance(reply_markup, markups):
# We need to_json() instead of to_dict() here, because reply_markups may be
# attached to media messages, which aren't json dumped by telegram.request
data['reply_markup'] = reply_markup.to_json()
@ -439,9 +442,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -647,9 +651,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
Telegram API.
@ -760,9 +765,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
thumb (`filelike object` | :obj:`bytes` | :class:`pathlib.Path`, optional): Thumbnail
of the file sent; can be ignored if
thumbnail generation for the file is supported server-side. The thumbnail should be
@ -882,9 +888,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
thumb (`filelike object` | :obj:`bytes` | :class:`pathlib.Path`, optional): Thumbnail
of the file sent; can be ignored if
thumbnail generation for the file is supported server-side. The thumbnail should be
@ -976,9 +983,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
Telegram API.
@ -1083,9 +1091,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
thumb (`filelike object` | :obj:`bytes` | :class:`pathlib.Path`, optional): Thumbnail
of the file sent; can be ignored if
thumbnail generation for the file is supported server-side. The thumbnail should be
@ -1198,9 +1207,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
thumb (`filelike object` | :obj:`bytes` | :class:`pathlib.Path`, optional): Thumbnail
of the file sent; can be ignored if
thumbnail generation for the file is supported server-side. The thumbnail should be
@ -1327,9 +1337,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
Telegram API.
@ -1439,9 +1450,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): Send file timeout (default: 20 seconds).
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
Telegram API.
@ -1589,9 +1601,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -1840,9 +1853,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -1944,9 +1958,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -5106,9 +5121,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -5194,7 +5210,8 @@ class Bot(TelegramObject):
data: JSONDict = {'chat_id': chat_id, 'message_id': message_id}
if reply_markup:
if isinstance(reply_markup, ReplyMarkup):
markups = (InlineKeyboardMarkup, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove)
if isinstance(reply_markup, markups):
# We need to_json() instead of to_dict() here, because reply_markups may be
# attached to media messages, which aren't json dumped by telegram.request
data['reply_markup'] = reply_markup.to_json()
@ -5247,9 +5264,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard, instructions
to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -5523,9 +5541,10 @@ class Bot(TelegramObject):
original message.
allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message
should be sent even if the specified replied-to message is not found.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Additional interface options.
An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
@ -5554,7 +5573,8 @@ class Bot(TelegramObject):
if reply_to_message_id:
data['reply_to_message_id'] = reply_to_message_id
if reply_markup:
if isinstance(reply_markup, ReplyMarkup):
markups = (InlineKeyboardMarkup, ReplyKeyboardMarkup, ForceReply, ReplyKeyboardRemove)
if isinstance(reply_markup, markups):
# We need to_json() instead of to_dict() here, because reply_markups may be
# attached to media messages, which aren't json dumped by telegram.request
data['reply_markup'] = reply_markup.to_json()

View file

@ -20,9 +20,9 @@
"""This module contains an object that represents a Telegram CallbackQuery"""
from typing import TYPE_CHECKING, Any, List, Optional, Union, Tuple, ClassVar
from telegram import Message, TelegramObject, User, Location, ReplyMarkup, constants
from telegram import Message, TelegramObject, User, Location, constants
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput, DVInput
from telegram._utils.types import JSONDict, ODVInput, DVInput, ReplyMarkup
if TYPE_CHECKING:
from telegram import (

View file

@ -22,7 +22,7 @@ from datetime import datetime
from typing import TYPE_CHECKING, List, Optional, ClassVar, Union, Tuple, Any
from telegram import ChatPhoto, TelegramObject, constants
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput, ReplyMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE, DEFAULT_20
from telegram._chatpermissions import ChatPermissions
@ -35,7 +35,6 @@ if TYPE_CHECKING:
ChatInviteLink,
Message,
MessageId,
ReplyMarkup,
Contact,
InlineKeyboardMarkup,
Location,
@ -740,7 +739,7 @@ class Chat(TelegramObject):
disable_web_page_preview: ODVInput[bool] = DEFAULT_NONE,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
@ -837,7 +836,7 @@ class Chat(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
@ -879,7 +878,7 @@ class Chat(TelegramObject):
last_name: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
contact: 'Contact' = None,
vcard: str = None,
@ -922,7 +921,7 @@ class Chat(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb: FileInput = None,
@ -969,7 +968,7 @@ class Chat(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb: FileInput = None,
@ -1011,7 +1010,7 @@ class Chat(TelegramObject):
self,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
emoji: str = None,
api_kwargs: JSONDict = None,
@ -1160,7 +1159,7 @@ class Chat(TelegramObject):
longitude: float = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
location: 'Location' = None,
live_period: int = None,
@ -1210,7 +1209,7 @@ class Chat(TelegramObject):
parse_mode: ODVInput[str] = DEFAULT_NONE,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
api_kwargs: JSONDict = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
@ -1253,7 +1252,7 @@ class Chat(TelegramObject):
sticker: Union[FileInput, 'Sticker'],
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
api_kwargs: JSONDict = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
@ -1290,7 +1289,7 @@ class Chat(TelegramObject):
foursquare_id: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
venue: 'Venue' = None,
foursquare_type: str = None,
@ -1337,7 +1336,7 @@ class Chat(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
width: int = None,
height: int = None,
@ -1388,7 +1387,7 @@ class Chat(TelegramObject):
length: int = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
thumb: FileInput = None,
api_kwargs: JSONDict = None,
@ -1429,7 +1428,7 @@ class Chat(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
@ -1477,7 +1476,7 @@ class Chat(TelegramObject):
is_closed: bool = None,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
explanation: str = None,
explanation_parse_mode: ODVInput[str] = DEFAULT_NONE,
@ -1531,7 +1530,7 @@ class Chat(TelegramObject):
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
@ -1572,7 +1571,7 @@ class Chat(TelegramObject):
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,

View file

@ -20,10 +20,10 @@
from typing import Any
from telegram import ReplyMarkup
from telegram import TelegramObject
class ForceReply(ReplyMarkup):
class ForceReply(TelegramObject):
"""
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

View file

@ -20,19 +20,20 @@
from typing import TYPE_CHECKING, Any, List, Optional
from telegram import InlineKeyboardButton, ReplyMarkup
from telegram import InlineKeyboardButton, TelegramObject
from telegram._utils.types import JSONDict
from telegram._utils.markup import check_keyboard_type
if TYPE_CHECKING:
from telegram import Bot
class InlineKeyboardMarkup(ReplyMarkup):
class InlineKeyboardMarkup(TelegramObject):
"""
This object represents an inline keyboard that appears right next to the message it belongs to.
Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their the size of :attr:`inline_keyboard` and all the buttons are equal.
considered equal, if their size of :attr:`inline_keyboard` and all the buttons are equal.
Args:
inline_keyboard (List[List[:class:`telegram.InlineKeyboardButton`]]): List of button rows,
@ -48,7 +49,7 @@ class InlineKeyboardMarkup(ReplyMarkup):
__slots__ = ('inline_keyboard',)
def __init__(self, inline_keyboard: List[List[InlineKeyboardButton]], **_kwargs: Any):
if not self._check_keyboard_type(inline_keyboard):
if not check_keyboard_type(inline_keyboard):
raise ValueError(
"The parameter `inline_keyboard` should be a list of "
"list of InlineKeyboardButtons"

View file

@ -20,11 +20,11 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultArticle(InlineQueryResult):
@ -35,8 +35,8 @@ class InlineQueryResultArticle(InlineQueryResult):
title (:obj:`str`): Title of the result.
input_message_content (:class:`telegram.InputMessageContent`): Content of the message to
be sent.
reply_markup (:class:`telegram.ReplyMarkup`, optional): Inline keyboard attached to
the message
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
to the message.
url (:obj:`str`, optional): URL of the result.
hide_url (:obj:`bool`, optional): Pass :obj:`True`, if you don't want the URL to be shown
in the message.
@ -52,8 +52,8 @@ class InlineQueryResultArticle(InlineQueryResult):
title (:obj:`str`): Title of the result.
input_message_content (:class:`telegram.InputMessageContent`): Content of the message to
be sent.
reply_markup (:class:`telegram.ReplyMarkup`): Optional. Inline keyboard attached to
the message.
reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
to the message.
url (:obj:`str`): Optional. URL of the result.
hide_url (:obj:`bool`): Optional. Pass :obj:`True`, if you don't want the URL to be shown
in the message.
@ -81,7 +81,7 @@ class InlineQueryResultArticle(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
title: str,
input_message_content: 'InputMessageContent',
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
url: str = None,
hide_url: bool = None,
description: str = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultAudio(InlineQueryResult):
@ -99,7 +99,7 @@ class InlineQueryResultAudio(InlineQueryResult):
performer: str = None,
audio_duration: int = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedAudio(InlineQueryResult):
@ -87,7 +87,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
id: str, # pylint: disable=redefined-builtin
audio_file_id: str,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -21,13 +21,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedDocument(InlineQueryResult):
@ -96,7 +96,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
document_file_id: str,
description: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedGif(InlineQueryResult):
@ -92,7 +92,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
gif_file_id: str,
title: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
@ -92,7 +92,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
mpeg4_file_id: str,
title: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -21,13 +21,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedPhoto(InlineQueryResult):
@ -97,7 +97,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
title: str = None,
description: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,11 +20,11 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedSticker(InlineQueryResult):
@ -59,7 +59,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
sticker_file_id: str,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
**_kwargs: Any,
):

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedVideo(InlineQueryResult):
@ -96,7 +96,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
title: str,
description: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultCachedVoice(InlineQueryResult):
@ -91,7 +91,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
voice_file_id: str,
title: str,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,11 +20,11 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultContact(InlineQueryResult):
@ -85,7 +85,7 @@ class InlineQueryResultContact(InlineQueryResult):
phone_number: str,
first_name: str,
last_name: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
thumb_url: str = None,
thumb_width: int = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultDocument(InlineQueryResult):
@ -111,7 +111,7 @@ class InlineQueryResultDocument(InlineQueryResult):
mime_type: str,
caption: str = None,
description: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
thumb_url: str = None,
thumb_width: int = None,

View file

@ -18,14 +18,11 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains the classes that represent Telegram InlineQueryResultGame."""
from typing import TYPE_CHECKING, Any
from typing import Any
from telegram import InlineQueryResult
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import ReplyMarkup
class InlineQueryResultGame(InlineQueryResult):
"""Represents a :class:`telegram.Game`.
@ -52,7 +49,7 @@ class InlineQueryResultGame(InlineQueryResult):
self,
id: str, # pylint: disable=redefined-builtin
game_short_name: str,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
**_kwargs: Any,
):
# Required

View file

@ -21,13 +21,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultGif(InlineQueryResult):
@ -113,7 +113,7 @@ class InlineQueryResultGif(InlineQueryResult):
gif_height: int = None,
title: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
gif_duration: int = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,

View file

@ -20,11 +20,11 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultLocation(InlineQueryResult):
@ -103,7 +103,7 @@ class InlineQueryResultLocation(InlineQueryResult):
longitude: float,
title: str,
live_period: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
thumb_url: str = None,
thumb_width: int = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultMpeg4Gif(InlineQueryResult):
@ -112,7 +112,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
mpeg4_height: int = None,
title: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
mpeg4_duration: int = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultPhoto(InlineQueryResult):
@ -109,7 +109,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
title: str = None,
description: str = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,11 +20,11 @@
from typing import TYPE_CHECKING, Any
from telegram import InlineQueryResult
from telegram import InlineQueryResult, InlineKeyboardMarkup
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultVenue(InlineQueryResult):
@ -105,7 +105,7 @@ class InlineQueryResultVenue(InlineQueryResult):
address: str,
foursquare_id: str = None,
foursquare_type: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
thumb_url: str = None,
thumb_width: int = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultVideo(InlineQueryResult):
@ -124,7 +124,7 @@ class InlineQueryResultVideo(InlineQueryResult):
video_height: int = None,
video_duration: int = None,
description: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -20,13 +20,13 @@
from typing import TYPE_CHECKING, Any, Union, Tuple, List
from telegram import InlineQueryResult, MessageEntity
from telegram import InlineQueryResult, MessageEntity, InlineKeyboardMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import ODVInput
from telegram.constants import InlineQueryResultType
if TYPE_CHECKING:
from telegram import InputMessageContent, ReplyMarkup
from telegram import InputMessageContent
class InlineQueryResultVoice(InlineQueryResult):
@ -96,7 +96,7 @@ class InlineQueryResultVoice(InlineQueryResult):
title: str,
voice_duration: int = None,
caption: str = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: InlineKeyboardMarkup = None,
input_message_content: 'InputMessageContent' = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Union[Tuple[MessageEntity, ...], List[MessageEntity]] = None,

View file

@ -50,7 +50,6 @@ from telegram import (
VoiceChatEnded,
VoiceChatParticipantsInvited,
ProximityAlertTriggered,
ReplyMarkup,
MessageAutoDeleteTimerChanged,
VoiceChatScheduled,
)
@ -58,7 +57,7 @@ from telegram.constants import ParseMode, MessageAttachmentType
from telegram.helpers import escape_markdown
from telegram._utils.datetime import from_timestamp, to_timestamp
from telegram._utils.defaultvalue import DEFAULT_NONE, DEFAULT_20, DefaultValue
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput, ReplyMarkup
if TYPE_CHECKING:
from telegram import (

View file

@ -20,11 +20,12 @@
from typing import Any, List, Union, Sequence
from telegram import KeyboardButton, ReplyMarkup
from telegram import KeyboardButton, TelegramObject
from telegram._utils.types import JSONDict
from telegram._utils.markup import check_keyboard_type
class ReplyKeyboardMarkup(ReplyMarkup):
class ReplyKeyboardMarkup(TelegramObject):
"""This object represents a custom keyboard with reply options.
Objects of this class are comparable in terms of equality. Two objects of this class are
@ -92,7 +93,7 @@ class ReplyKeyboardMarkup(ReplyMarkup):
input_field_placeholder: str = None,
**_kwargs: Any,
):
if not self._check_keyboard_type(keyboard):
if not check_keyboard_type(keyboard):
raise ValueError(
"The parameter `keyboard` should be a list of list of "
"strings or KeyboardButtons"

View file

@ -19,10 +19,10 @@
"""This module contains an object that represents a Telegram ReplyKeyboardRemove."""
from typing import Any
from telegram import ReplyMarkup
from telegram import TelegramObject
class ReplyKeyboardRemove(ReplyMarkup):
class ReplyKeyboardRemove(TelegramObject):
"""
Upon receiving a message with this object, Telegram clients will remove the current custom
keyboard and display the default letter-keyboard. By default, custom keyboards are displayed

View file

@ -1,42 +0,0 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
# 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/].
"""Base class for Telegram ReplyMarkup Objects."""
from telegram import TelegramObject
class ReplyMarkup(TelegramObject):
"""Base class for Telegram ReplyMarkup Objects.
See :class:`telegram.InlineKeyboardMarkup`, :class:`telegram.ReplyKeyboardMarkup`,
:class:`telegram.ReplyKeyboardRemove` and :class:`telegram.ForceReply` for
detailed use.
"""
__slots__ = ()
@staticmethod
def _check_keyboard_type(keyboard: object) -> bool:
"""Checks if the keyboard provided is of the correct type - A list of lists."""
if not isinstance(keyboard, list):
return False
for row in keyboard:
if not isinstance(row, list):
return False
return True

View file

@ -28,7 +28,7 @@ from telegram.helpers import (
mention_html as helpers_mention_html,
)
from telegram._utils.defaultvalue import DEFAULT_NONE, DEFAULT_20
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput
from telegram._utils.types import JSONDict, FileInput, ODVInput, DVInput, ReplyMarkup
if TYPE_CHECKING:
from telegram import (
@ -41,7 +41,6 @@ if TYPE_CHECKING:
InputMediaPhoto,
InputMediaVideo,
MessageEntity,
ReplyMarkup,
PhotoSize,
Audio,
Contact,
@ -331,7 +330,7 @@ class User(TelegramObject):
disable_web_page_preview: ODVInput[bool] = DEFAULT_NONE,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
@ -369,7 +368,7 @@ class User(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
@ -446,7 +445,7 @@ class User(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb: FileInput = None,
@ -519,7 +518,7 @@ class User(TelegramObject):
last_name: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
contact: 'Contact' = None,
vcard: str = None,
@ -557,7 +556,7 @@ class User(TelegramObject):
self,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
emoji: str = None,
api_kwargs: JSONDict = None,
@ -593,7 +592,7 @@ class User(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
thumb: FileInput = None,
@ -751,7 +750,7 @@ class User(TelegramObject):
longitude: float = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
location: 'Location' = None,
live_period: int = None,
@ -801,7 +800,7 @@ class User(TelegramObject):
parse_mode: ODVInput[str] = DEFAULT_NONE,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
api_kwargs: JSONDict = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
@ -844,7 +843,7 @@ class User(TelegramObject):
sticker: Union[FileInput, 'Sticker'],
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
api_kwargs: JSONDict = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
@ -879,7 +878,7 @@ class User(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
width: int = None,
height: int = None,
@ -932,7 +931,7 @@ class User(TelegramObject):
foursquare_id: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
venue: 'Venue' = None,
foursquare_type: str = None,
@ -979,7 +978,7 @@ class User(TelegramObject):
length: int = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
thumb: FileInput = None,
api_kwargs: JSONDict = None,
@ -1020,7 +1019,7 @@ class User(TelegramObject):
caption: str = None,
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: DVInput[float] = DEFAULT_20,
parse_mode: ODVInput[str] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
@ -1068,7 +1067,7 @@ class User(TelegramObject):
is_closed: bool = None,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
explanation: str = None,
explanation_parse_mode: ODVInput[str] = DEFAULT_NONE,
@ -1122,7 +1121,7 @@ class User(TelegramObject):
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
@ -1163,7 +1162,7 @@ class User(TelegramObject):
disable_notification: DVInput[bool] = DEFAULT_NONE,
reply_to_message_id: int = None,
allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE,
reply_markup: 'ReplyMarkup' = None,
reply_markup: ReplyMarkup = None,
timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,

41
telegram/_utils/markup.py Normal file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
# 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 a helper function for Telegram's ReplyMarkups
.. versionchanged:: 14.0
Previously, the contents of this module were available through the (no longer existing)
class ``telegram.ReplyMarkup``.
Warning:
Contents of this module are intended to be used internally by the library and *not* by the
user. Changes to this module are not considered breaking changes and may not be documented in
the changelog.
"""
def check_keyboard_type(keyboard: object) -> bool:
"""Checks if the keyboard provided is of the correct type - A list of lists.
Implicitly tested in the init-tests of `{Inline, Reply}KeyboardMarkup`
"""
if not isinstance(keyboard, list):
return False
for row in keyboard:
if not isinstance(row, list):
return False
return True

View file

@ -39,6 +39,7 @@ from typing import (
if TYPE_CHECKING:
from telegram import InputFile # noqa: F401
from telegram._utils.defaultvalue import DefaultValue # noqa: F401
from telegram import InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply
FileLike = Union[IO, 'InputFile']
"""Either an open file handler or a :class:`telegram.InputFile`."""
@ -64,3 +65,11 @@ as ``Union[DefaultValue, type]``."""
RT = TypeVar("RT")
SLT = Union[RT, List[RT], Tuple[RT, ...]]
"""Single instance or list/tuple of instances."""
ReplyMarkup = Union[
'InlineKeyboardMarkup', 'ReplyKeyboardMarkup', 'ReplyKeyboardRemove', 'ForceReply'
]
"""Type alias for reply markup objects.
.. versionadded:: 14.0
"""

View file

@ -37,7 +37,6 @@ from typing import (
from telegram import (
Bot,
ReplyMarkup,
Message,
InlineKeyboardMarkup,
Poll,
@ -48,7 +47,7 @@ from telegram import (
InputMedia,
)
from telegram._utils.types import JSONDict, ODVInput, DVInput
from telegram._utils.types import JSONDict, ODVInput, DVInput, ReplyMarkup
from telegram._utils.defaultvalue import DEFAULT_NONE, DefaultValue
from telegram._utils.datetime import to_timestamp
from telegram.ext._callbackdatacache import CallbackDataCache

View file

@ -20,7 +20,13 @@
import pytest
from flaky import flaky
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyMarkup, ReplyKeyboardMarkup
from telegram import (
InlineKeyboardButton,
InlineKeyboardMarkup,
ForceReply,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
)
@pytest.fixture(scope='class')
@ -100,7 +106,13 @@ class TestInlineKeyboardMarkup:
**kwargs,
):
if reply_markup is not None:
if isinstance(reply_markup, ReplyMarkup):
markups = (
InlineKeyboardMarkup,
ReplyKeyboardMarkup,
ForceReply,
ReplyKeyboardRemove,
)
if isinstance(reply_markup, markups):
data['reply_markup'] = reply_markup.to_dict()
else:
data['reply_markup'] = reply_markup