MaybeInaccessibleMessage

class telegram.MaybeInaccessibleMessage(chat, message_id, date, *, api_kwargs=None)[source]

Bases: telegram.TelegramObject

Base class for Telegram Message Objects.

Currently, that includes telegram.Message and telegram.InaccessibleMessage.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their message_id and chat are equal

New in version 20.8.

Parameters:
message_id[source]

Unique message identifier.

Type:

int

date[source]

Date the message was sent in Unix time or 0 in Unix time. Converted to datetime.datetime

The default timezone of the bot is used for localization, which is UTC unless telegram.ext.Defaults.tzinfo is used.

Type:

datetime.datetime

chat[source]

Conversation the message belongs to.

Type:

telegram.Chat

__bool__()[source]

Overrides object.__bool__() to return the value of is_accessible. This is intended to ease migration to Bot API 7.0, as this allows checks like

if message.pinned_message:
    ...

to work as before, when message.pinned_message was None. Note that this does not help with check like

if message.pinned_message is None:
    ...

for cases where message.pinned_message is now no longer None.

Tip

Since objects that can only be of type Message or None are not affected by this change, Message.__bool__() is not overridden and will continue to work as before.

New in version 20.8.

Deprecated since version 20.8: This behavior is introduced only temporarily to ease migration to Bot API 7.0. It will be removed along with other functionality deprecated by Bot API 7.0.

classmethod de_json(data, bot)[source]

See telegram.TelegramObject.de_json().

property is_accessible[source]

Convenience attribute. True, if the date is not 0 in Unix time.

New in version 20.8.