Chat
Represents a chat in MAX messenger.
Attributes
| Attribute | Type | Description |
|---|---|---|
id |
int |
Unique chat identifier |
type |
str |
Chat type: private, group, supergroup, channel |
title |
str |
Chat title (for groups/channels) |
username |
str |
Chat username (if public) |
first_name |
str |
First name (for private chats) |
last_name |
str |
Last name (for private chats) |
photo |
ChatPhoto |
Chat photo (if set) |
description |
str |
Chat description (for groups/channels) |
Chat Types
from aiomax.enums import ChatType
ChatType.PRIVATE # "private"
ChatType.GROUP # "group"
ChatType.SUPERGROUP # "supergroup"
ChatType.CHANNEL # "channel"
Methods
get_members()
Get list of chat members.
get_member(user_id)
Get a specific chat member.
member = await chat.get_member(user_id=123456)
print(member.status) # "administrator", "member", etc.
kick_member(user_id)
Kick a member from the chat.
ban_member(user_id)
Ban a member from the chat.
unban_member(user_id)
Unban a previously banned member.
set_description(description)
Set chat description.
set_photo(photo)
Set chat photo.
delete_photo()
Delete chat photo.
Example
@bot.on_message(filters.group)
async def handle_group(message):
chat = message.chat
if chat.type == "supergroup":
await bot.send_message(
chat_id=chat.id,
text=f"Welcome to {chat.title}!"
)
See Also
- Message - Message object
- User - User object
- Chat Actions - Available chat actions