Message
Represents a message in MAX messenger.
Attributes
| Attribute | Type | Description |
|---|---|---|
id |
int |
Unique message identifier |
chat |
Chat |
Chat where the message was sent |
from_user |
User |
Sender of the message |
text |
str |
Text content of the message |
date |
datetime |
Date when the message was sent |
reply_to_message |
Message |
Replied message (if any) |
Methods
reply(text, **kwargs)
Reply to this message.
forward(chat_id)
Forward this message to another chat.
delete()
Delete this message.
edit_text(text)
Edit the text of this message.
Example
@bot.on_message()
async def echo_with_reply(message):
# Reply to the message
await message.reply(f"You said: {message.text}")
# Access sender info
username = message.from_user.username
# Access chat info
chat_title = message.chat.title