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, *, api_kwargs=None)[source]¶
Bases:
telegram.TelegramObjectThis 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_idis equal.Note
At most one of the optional parameters can be present in any given update.
See also
- 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_MEMBERin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.ext.Application.run_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_usersadministrator right in the chat to receive these updates.New in version 13.8.
- update_id[source]¶
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.
- Type:
- edited_message[source]¶
Optional. New version of a message that is known to the bot and was edited.
- Type:
- channel_post[source]¶
Optional. New incoming channel post of any kind - text, photo, sticker, etc.
- Type:
- edited_channel_post[source]¶
Optional. New version of a channel post that is known to the bot and was edited.
- Type:
- chosen_inline_result[source]¶
Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
- shipping_query[source]¶
Optional. New incoming shipping query. Only for invoices with flexible price.
- Type:
- pre_checkout_query[source]¶
Optional. New incoming pre-checkout query. Contains full information about checkout.
- poll[source]¶
Optional. New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.
- Type:
- poll_answer[source]¶
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:
- my_chat_member[source]¶
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[source]¶
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_MEMBERin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.ext.Application.run_webhook()).New in version 13.4.
- chat_join_request[source]¶
Optional. A request to join the chat has been sent. The bot must have the
telegram.ChatPermissions.can_invite_usersadministrator right in the chat to receive these updates.New in version 13.8.
- Type:
- ALL_TYPES = [<UpdateType.MESSAGE>, <UpdateType.EDITED_MESSAGE>, <UpdateType.CHANNEL_POST>, <UpdateType.EDITED_CHANNEL_POST>, <UpdateType.INLINE_QUERY>, <UpdateType.CHOSEN_INLINE_RESULT>, <UpdateType.CALLBACK_QUERY>, <UpdateType.SHIPPING_QUERY>, <UpdateType.PRE_CHECKOUT_QUERY>, <UpdateType.POLL>, <UpdateType.POLL_ANSWER>, <UpdateType.MY_CHAT_MEMBER>, <UpdateType.CHAT_MEMBER>, <UpdateType.CHAT_JOIN_REQUEST>][source]¶
A list of all available update types.
New in version 13.5.
- Type:
List[
str]
- CALLBACK_QUERY = 'callback_query'[source]¶
telegram.constants.UpdateType.CALLBACK_QUERYNew in version 13.5.
- CHANNEL_POST = 'channel_post'[source]¶
telegram.constants.UpdateType.CHANNEL_POSTNew in version 13.5.
- CHAT_JOIN_REQUEST = 'chat_join_request'[source]¶
telegram.constants.UpdateType.CHAT_JOIN_REQUESTNew in version 13.8.
- CHAT_MEMBER = 'chat_member'[source]¶
telegram.constants.UpdateType.CHAT_MEMBERNew in version 13.5.
- CHOSEN_INLINE_RESULT = 'chosen_inline_result'[source]¶
telegram.constants.UpdateType.CHOSEN_INLINE_RESULTNew in version 13.5.
- EDITED_CHANNEL_POST = 'edited_channel_post'[source]¶
telegram.constants.UpdateType.EDITED_CHANNEL_POSTNew in version 13.5.
- EDITED_MESSAGE = 'edited_message'[source]¶
telegram.constants.UpdateType.EDITED_MESSAGENew in version 13.5.
- INLINE_QUERY = 'inline_query'[source]¶
telegram.constants.UpdateType.INLINE_QUERYNew in version 13.5.
- MESSAGE = 'message'[source]¶
telegram.constants.UpdateType.MESSAGENew in version 13.5.
- MY_CHAT_MEMBER = 'my_chat_member'[source]¶
telegram.constants.UpdateType.MY_CHAT_MEMBERNew in version 13.5.
- POLL = 'poll'[source]¶
telegram.constants.UpdateType.POLLNew in version 13.5.
- POLL_ANSWER = 'poll_answer'[source]¶
telegram.constants.UpdateType.POLL_ANSWERNew in version 13.5.
- PRE_CHECKOUT_QUERY = 'pre_checkout_query'[source]¶
telegram.constants.UpdateType.PRE_CHECKOUT_QUERYNew in version 13.5.
- SHIPPING_QUERY = 'shipping_query'[source]¶
telegram.constants.UpdateType.SHIPPING_QUERYNew in version 13.5.
- property effective_chat[source]¶
The chat that this update was sent in, no matter what kind of update this is. If no chat is associated with this update, this gives
None. This is the case, ifinline_query,chosen_inline_result,callback_queryfrom inline messages,shipping_query,pre_checkout_query,pollorpoll_answeris present.Example
If
messageis present, this will givetelegram.Message.chat.- Type:
- property effective_message[source]¶
The message included in this update, no matter what kind of update this is. More precisely, this will be the message contained in
message,edited_message,channel_post,edited_channel_postorcallback_query(i.e.telegram.CallbackQuery.message) orNone, if none of those are present.- Type:
- property effective_user[source]¶
The user that sent this update, no matter what kind of update this is. If no user is associated with this update, this gives
None. This is the case ifchannel_post,edited_channel_postorpollis present.Example
If
messageis present, this will givetelegram.Message.from_user.If
poll_answeris present, this will givetelegram.PollAnswer.user.
- Type: