MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / CallbackQuery

Class CallbackQuery

src/telegram/_callbackquery.py:50–939  ·  view source on GitHub ↗

This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field :attr:`message` will be present. If the button was attached to a message sent via the bot (in

Source from the content-addressed store, hash-verified

48
49
50class CallbackQuery(TelegramObject):
51 """
52 This object represents an incoming callback query from a callback button in an inline keyboard.
53
54 If the button that originated the query was attached to a message sent by the bot, the field
55 :attr:`message` will be present. If the button was attached to a message sent via the bot (in
56 inline mode), the field :attr:`inline_message_id` will be present.
57
58 Objects of this class are comparable in terms of equality. Two objects of this class are
59 considered equal, if their :attr:`id` is equal.
60
61 Note:
62 * In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.
63 * Exactly one of the fields :attr:`data` or :attr:`game_short_name` will be present.
64 * After the user presses an inline button, Telegram clients will display a progress bar
65 until you call :attr:`answer`. It is, therefore, necessary to react
66 by calling :attr:`telegram.Bot.answer_callback_query` even if no notification to the user
67 is needed (e.g., without specifying any of the optional parameters).
68 * If you're using :attr:`telegram.ext.ExtBot.callback_data_cache`, :attr:`data` may be
69 an instance
70 of :class:`telegram.ext.InvalidCallbackData`. This will be the case, if the data
71 associated with the button triggering the :class:`telegram.CallbackQuery` was already
72 deleted or if :attr:`data` was manipulated by a malicious client.
73
74 .. versionadded:: 13.6
75
76 Args:
77 id (:obj:`str`): Unique identifier for this query.
78 from_user (:class:`telegram.User`): Sender.
79 chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
80 the message with the callback button was sent. Useful for high scores in games.
81 message (:class:`telegram.MaybeInaccessibleMessage`, optional): Message sent by the bot
82 with the callback button that originated the query.
83
84 .. versionchanged:: 20.8
85 Accept objects of type :class:`telegram.MaybeInaccessibleMessage` since Bot API 7.0.
86 data (:obj:`str`, optional): Data associated with the callback button. Be aware that the
87 message, which originated the query, can contain no callback buttons with this data.
88 inline_message_id (:obj:`str`, optional): Identifier of the message sent via the bot in
89 inline mode, that originated the query.
90 game_short_name (:obj:`str`, optional): Short name of a Game to be returned, serves as
91 the unique identifier for the game.
92
93 Attributes:
94 id (:obj:`str`): Unique identifier for this query.
95 from_user (:class:`telegram.User`): Sender.
96 chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
97 the message with the callback button was sent. Useful for high scores in games.
98 message (:class:`telegram.MaybeInaccessibleMessage`): Optional. Message sent by the bot
99 with the callback button that originated the query.
100
101 .. versionchanged:: 20.8
102 Objects may be of type :class:`telegram.MaybeInaccessibleMessage` since Bot API
103 7.0.
104 data (:obj:`str` | :obj:`object`): Optional. Data associated with the callback button.
105 Be aware that the message, which originated the query, can contain no callback buttons
106 with this data.
107

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…