Message

class bale.Message(message_id, date, text=MissingValue, caption=MissingValue, forward_from=MissingValue, forward_from_chat=MissingValue, forward_from_message_id=MissingValue, from_user=MissingValue, document=MissingValue, contact=MissingValue, edit_date=MissingValue, location=MissingValue, chat=MissingValue, video=MissingValue, photos=MissingValue, sticker=MissingValue, reply_to_message=MissingValue, invoice=MissingValue, audio=MissingValue, voice=MissingValue, successful_payment=MissingValue, animation=MissingValue, new_chat_members=MissingValue, left_chat_member=MissingValue)

Bases: BaleObject

This object shows a message.

message_id

Unique message identifier inside this chat.

Type:

str

from_user

Sender of the message; empty for messages sent to channels. For backward compatibility, this will contain a fake sender user in non-channel chats, if the message was sent on behalf of a chat.

Note

from_user is an Aliases for from. Because from is a reserved character in Python.

Type:

bale.User, optional

chat

Conversation the message belongs to.

Type:

bale.Chat

date

Date the message was sent in Unix time.

Type:

datetime.datetime

text

Message Content

Type:

str, optional

caption

Caption for the animation, audio, document, photo, video or voice.

Type:

str, optional

forward_from

For forwarded messages, sender of the original message.

Type:

bale.User, optional

forward_from_chat

For messages forwarded from channels or from anonymous administrators, information about the original sender chat.

Type:

bale.Chat, optional

reply_to_message

For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.

Type:

bale.Message, optional

edit_date

Date the message was last edited.

Type:

datetime.datetime, optional

contact

Message is a shared contact, information about the contact.

Type:

bale.Contact, optional

location

Message is a shared location, information about the location.

Type:

bale.Location, optional

document

Message is a general file, information about the file.

Type:

bale.Document, optional

video

Message is a video, information about the video.

Type:

bale.Video, optional

animation

Message is an animation, information about the animation.

Type:

bale.Animation, optional

audio

Message is an audio, information about the Audio.

Type:

bale.Audio, optional

voice

Message is a voice, information about the Voice.

Type:

bale.Voice, optional

sticker

Message is a sticker, information about the sticker.

Type:

bale.Sticker, optional

new_chat_members

New members that were added to the group or supergroup and information about them (the bot itself may be one of these members). This list is empty if the message does not contain new chat members.

Type:

List[bale.User], optional

left_chat_member

A member was removed from the group, information about them (this member may be the bot itself).

Type:

bale.User, optional

invoice

Message is an invoice for a payment, information about the invoice.

Type:

bale.Invoice, optional

successful_payment

Message is a service message about a successful payment, information about the payment.

Type:

bale.SuccessfulPayment, optional

property attachment

Represents the message attachment. None if the message don’t have any attachments

Type:

Union[bale.Video, List[bale.PhotoSize], bale.Document, bale.Animation], optional

property author

An alias for from_user

property chat_id

Represents the Unique identifier of Conversation the message belongs to.

Type:

str | int

property content

Represents the message content. None if the message don’t have text or caption

Type:

str, optional

async copy(chat_id, reply_to_message_id=MissingValue, delete_after=None)

Shortcut method for:

await bot.copy_message(
    from_chat_id=message.chat_id, message_id=message.id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.copy_message().

async delete(*, delay=None)

Shortcut method for:

await bot.delete_message(
    chat_id=message.chat_id, message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.delete_message().

Hint

await message.delete(delay=5)
async edit(text, *, components=MissingValue)

Shortcut method for:

await bot.edit_message(
    chat_id=message.chat_id, message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.edit_message().

Hint

await message.edit("Bye!", components = None)
async edit_caption(caption, *, components=MissingValue)

Shortcut method for:

await bot.edit_message_caption(
    chat_id=message.chat_id, message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.edit_message_caption().

Hint

await message.edit_caption("Edited!", components = None)
async forward(chat_id)

Shortcut method for:

await bot.send_message(
    message_id=message.chat_id, from_chat_id=message.from_chat_id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.forward_message().

Hint

await message.forward(1234)
property id

An alias for message_id

async reply(text, *, components=MissingValue, delete_after=None)

Shortcut method for:

await bot.send_message(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_message().

Hint

await message.reply("Hi, python-bale-bot!", components = None)
async reply_animation(animation, *, duration=MissingValue, width=MissingValue, height=MissingValue, caption=MissingValue, components=MissingValue, delete_after=None, file_name=None)

Shortcut method for:

await bot.send_animation(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_animation().

Hint

await message.reply_animation(bale.InputFile("FILE_ID"), caption = "this is a caption", *args, **kwargs)
async reply_audio(audio, *, caption=MissingValue, components=MissingValue, delete_after=None, file_name=None)

Shortcut method for:

await bot.send_audio(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_audio().

Hint

await message.reply_audio(bale.InputFile("FILE_ID"), caption = "this is a caption", ...)
async reply_contact(contact, *, components=MissingValue, delete_after=None)

Shortcut method for:

await bot.send_contact(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_contact().

Hint

await message.reply_contact(bale.Contact('09****', 'first name', 'last name'))
async reply_document(document, *, caption=MissingValue, components=MissingValue, delete_after=None, file_name=None)

Shortcut method for:

await bot.send_document(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_document().

Hint

await message.reply_document(bale.InputFile("FILE_ID"), caption = "this is a caption", ...)
async reply_location(location, *, components=MissingValue, delete_after=None)

Shortcut method for:

await bot.send_location(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_audio().

Hint

await message.reply_location(bale.Location(35.71470468031143, 51.8568519168293))
async reply_media_group(media, *, components=MissingValue)

Shortcut method for:

await bot.send_media_group(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_media_group().

Hint

await message.reply_media_group([
    InputMediaPhoto("File ID", caption="example caption"),
    InputMediaPhoto("File ID"),
    InputMediaPhoto("File ID")
], ...)
async reply_photo(photo, *, caption=MissingValue, components=MissingValue, delete_after=None, file_name=None)

Shortcut method for:

await bot.send_photo(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_photo().

Hint

await message.reply_photo(bale.InputFile("FILE_ID"), caption = "this is a caption", ...)
async reply_sticker(sticker, *, delete_after=None)

Shortcut method for:

await bot.send_sticker(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_sticker().

Hint

await message.reply_sticker("File ID", *args, **kwargs)
property reply_to_message_id

Represents the Unique identifier of Original message, if the message has been replied. None If the message is not replied

Type:

str, optional

async reply_video(video, *, caption=MissingValue, components=MissingValue, delete_after=None, file_name=None)

Shortcut method for:

await bot.send_video(
    chat_id=message.chat_id, reply_to_message_id=message.id, *args, **kwargs
)

For the documentation of the arguments, please see bale.Bot.send_video().

Hint

await message.reply_video(bale.InputFile("FILE_ID"), caption = "this is a caption", ...)