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

Class Message

src/telegram/_message.py:266–6126  ·  view source on GitHub ↗

This object represents a message. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :attr:`message_id` and :attr:`chat` are equal. Note: In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` ins

Source from the content-addressed store, hash-verified

264
265
266class Message(MaybeInaccessibleMessage):
267 # fmt: off
268 """This object represents a message.
269
270 Objects of this class are comparable in terms of equality. Two objects of this class are
271 considered equal, if their :attr:`message_id` and :attr:`chat` are equal.
272
273 Note:
274 In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.
275
276 .. versionchanged:: 21.0
277 Removed deprecated arguments and attributes ``user_shared``, ``forward_from``,
278 ``forward_from_chat``, ``forward_from_message_id``, ``forward_signature``,
279 ``forward_sender_name`` and ``forward_date``.
280
281 .. versionchanged:: 20.8
282 * This class is now a subclass of :class:`telegram.MaybeInaccessibleMessage`.
283 * The :paramref:`pinned_message` now can be either :class:`telegram.Message` or
284 :class:`telegram.InaccessibleMessage`.
285
286 .. versionchanged:: 20.0
287
288 * The arguments and attributes ``voice_chat_scheduled``, ``voice_chat_started`` and
289 ``voice_chat_ended``, ``voice_chat_participants_invited`` were renamed to
290 :paramref:`video_chat_scheduled`/:attr:`video_chat_scheduled`,
291 :paramref:`video_chat_started`/:attr:`video_chat_started`,
292 :paramref:`video_chat_ended`/:attr:`video_chat_ended` and
293 :paramref:`video_chat_participants_invited`/:attr:`video_chat_participants_invited`,
294 respectively, in accordance to Bot API 6.0.
295 * The following are now keyword-only arguments in Bot methods:
296 ``{read, write, connect, pool}_timeout``, ``api_kwargs``, ``contact``, ``quote``,
297 ``filename``, ``loaction``, ``venue``. Use a named argument for those,
298 and notice that some positional arguments changed position as a result.
299
300 Args:
301 message_id (:obj:`int`): Unique message identifier inside this chat. In specific instances
302 (e.g., message containing a video sent to a big chat), the server might automatically
303 schedule a message instead of sending it immediately. In such cases, this field will be
304 ``0`` and the relevant message will be unusable until it is actually sent.
305 from_user (:class:`telegram.User`, optional): Sender of the message; may be empty for
306 messages sent to channels. For backward compatibility, if the message was sent on
307 behalf of a chat, the field contains a fake sender user in non-channel chats.
308 sender_chat (:class:`telegram.Chat`, optional): Sender of the message when sent on behalf
309 of a chat. For example, the supergroup itself for messages sent by its anonymous
310 administrators or a linked channel for messages automatically forwarded to the
311 channel's discussion group. For backward compatibility, if the message was sent on
312 behalf of a chat, the field from contains a fake sender user in non-channel chats.
313 date (:class:`datetime.datetime`): Date the message was sent in Unix time. Converted to
314 :class:`datetime.datetime`.
315
316 .. versionchanged:: 20.3
317 |datetime_localization|
318 chat (:class:`telegram.Chat`): Conversation the message belongs to.
319 is_automatic_forward (:obj:`bool`, optional): :obj:`True`, if the message is a channel
320 post that was automatically forwarded to the connected discussion group.
321
322 .. versionadded:: 13.9
323 reply_to_message (:class:`telegram.Message`, optional): For replies, the original message.

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…