telegram.Update

class telegram.Update(update_id, message=None, edited_message=None, channel_post=None, edited_channel_post=None, inline_query=None, chosen_inline_result=None, callback_query=None, shipping_query=None, pre_checkout_query=None, poll=None, poll_answer=None, my_chat_member=None, chat_member=None, chat_join_request=None, **_kwargs)

Bases: telegram.base.TelegramObject

This object represents an incoming update.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their update_id is equal.

Note

At most one of the optional parameters can be present in any given update.

Parameters
  • update_id (int) – The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

  • message (telegram.Message, optional) – New incoming message of any kind - text, photo, sticker, etc.

  • edited_message (telegram.Message, optional) – New version of a message that is known to the bot and was edited.

  • channel_post (telegram.Message, optional) – New incoming channel post of any kind - text, photo, sticker, etc.

  • edited_channel_post (telegram.Message, optional) – New version of a channel post that is known to the bot and was edited.

  • inline_query (telegram.InlineQuery, optional) – New incoming inline query.

  • chosen_inline_result (telegram.ChosenInlineResult, optional) – The result of an inline query that was chosen by a user and sent to their chat partner.

  • callback_query (telegram.CallbackQuery, optional) – New incoming callback query.

  • shipping_query (telegram.ShippingQuery, optional) – New incoming shipping query. Only for invoices with flexible price.

  • pre_checkout_query (telegram.PreCheckoutQuery, optional) – New incoming pre-checkout query. Contains full information about checkout.

  • poll (telegram.Poll, optional) – New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.

  • poll_answer (telegram.PollAnswer, optional) – A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

  • my_chat_member (telegram.ChatMemberUpdated, optional) –

    The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

    New in version 13.4.

  • chat_member (telegram.ChatMemberUpdated, optional) –

    A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify 'chat_member' in the list of 'allowed_updates' to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Updater.start_polling() and telegram.ext.Updater.start_webhook()).

    New in version 13.4.

  • chat_join_request (telegram.ChatJoinRequest, optional) –

    A request to join the chat has been sent. The bot must have the telegram.ChatPermissions.can_invite_users administrator right in the chat to receive these updates.

    New in version 13.8.

  • **kwargs (dict) – Arbitrary keyword arguments.

update_id

The update’s unique identifier.

Type

int

message

Optional. New incoming message.

Type

telegram.Message

edited_message

Optional. New version of a message.

Type

telegram.Message

channel_post

Optional. New incoming channel post.

Type

telegram.Message

edited_channel_post

Optional. New version of a channel post.

Type

telegram.Message

inline_query

Optional. New incoming inline query.

Type

telegram.InlineQuery

chosen_inline_result

Optional. The result of an inline query that was chosen by a user.

Type

telegram.ChosenInlineResult

callback_query

Optional. New incoming callback query.

Type

telegram.CallbackQuery

shipping_query

Optional. New incoming shipping query.

Type

telegram.ShippingQuery

pre_checkout_query

Optional. New incoming pre-checkout query.

Type

telegram.PreCheckoutQuery

poll

Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.

Type

telegram.Poll

poll_answer

Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

Type

telegram.PollAnswer

my_chat_member

Optional. The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

New in version 13.4.

Type

telegram.ChatMemberUpdated

chat_member

Optional. A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify 'chat_member' in the list of 'allowed_updates' to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Updater.start_polling() and telegram.ext.Updater.start_webhook()).

New in version 13.4.

Type

telegram.ChatMemberUpdated

chat_join_request

Optional. A request to join the chat has been sent. The bot must have the 'can_invite_users' administrator right in the chat to receive these updates.

New in version 13.8.

Type

telegram.ChatJoinRequest

ALL_TYPES = ['message', 'edited_message', 'channel_post', 'edited_channel_post', 'inline_query', 'chosen_inline_result', 'callback_query', 'shipping_query', 'pre_checkout_query', 'poll', 'poll_answer', 'my_chat_member', 'chat_member', 'chat_join_request']

telegram.constants.UPDATE_ALL_TYPES

New in version 13.5.

CALLBACK_QUERY = 'callback_query'

telegram.constants.UPDATE_CALLBACK_QUERY

New in version 13.5.

CHANNEL_POST = 'channel_post'

telegram.constants.UPDATE_CHANNEL_POST

New in version 13.5.

CHAT_JOIN_REQUEST = 'chat_join_request'

telegram.constants.UPDATE_CHAT_JOIN_REQUEST

New in version 13.8.

CHAT_MEMBER = 'chat_member'

telegram.constants.UPDATE_CHAT_MEMBER

New in version 13.5.

CHOSEN_INLINE_RESULT = 'chosen_inline_result'

telegram.constants.UPDATE_CHOSEN_INLINE_RESULT

New in version 13.5.

EDITED_CHANNEL_POST = 'edited_channel_post'

telegram.constants.UPDATE_EDITED_CHANNEL_POST

New in version 13.5.

EDITED_MESSAGE = 'edited_message'

telegram.constants.UPDATE_EDITED_MESSAGE

New in version 13.5.

INLINE_QUERY = 'inline_query'

telegram.constants.UPDATE_INLINE_QUERY

New in version 13.5.

MESSAGE = 'message'

telegram.constants.UPDATE_MESSAGE

New in version 13.5.

MY_CHAT_MEMBER = 'my_chat_member'

telegram.constants.UPDATE_MY_CHAT_MEMBER

New in version 13.5.

POLL = 'poll'

telegram.constants.UPDATE_POLL

New in version 13.5.

POLL_ANSWER = 'poll_answer'

telegram.constants.UPDATE_POLL_ANSWER

New in version 13.5.

PRE_CHECKOUT_QUERY = 'pre_checkout_query'

telegram.constants.UPDATE_PRE_CHECKOUT_QUERY

New in version 13.5.

SHIPPING_QUERY = 'shipping_query'

telegram.constants.UPDATE_SHIPPING_QUERY

New in version 13.5.

classmethod de_json(data, bot)

See telegram.TelegramObject.de_json().

property effective_chat

The chat that this update was sent in, no matter what kind of update this is. Will be None for inline_query, chosen_inline_result, callback_query from inline messages, shipping_query, pre_checkout_query, poll and poll_answer.

Type

telegram.Chat

property effective_message

The message included in this update, no matter what kind of update this is. Will be None for inline_query, chosen_inline_result, callback_query from inline messages, shipping_query, pre_checkout_query, poll, poll_answer, my_chat_member, chat_member as well as chat_join_request in case the bot is missing the telegram.ChatPermissions.can_invite_users administrator right in the chat.

Type

telegram.Message

property effective_user

The user that sent this update, no matter what kind of update this is. Will be None for channel_post and poll.

Type

telegram.User