English فارسی

Types & models

Thin, readable wrappers over the decoded protocol dicts. Each one keeps the raw payload in .raw, so nothing is ever lost.

Message

57 public members. The ones you will actually use:

MemberReturns
id / message_idMessage id
textPlain text or ""
contentStructured body dict
chat / chat_idConversation
from_user / sender / sender_idAuthor
is_outgoing / is_incomingDirection
is_reply / reply_to_messageQuoting
photo, document, video, voice, audio, sticker, location, contact, pollTyped media accessors or None
mediaWhatever media the message carries
buttonsInline keyboard rows
command / command_args"/start", "foo bar"
matchesRegex groups when a pattern filter matched
reply_to_message_idint
print(message.text)
print(message.is_outgoing)
print(message.command, message.command_args)
print(message.photo.width if message.photo else None)

Actions

MethodDoes
answer(text) / reply(text)Reply in the same chat
reply_photo, reply_document, reply_voice, reply_video, reply_audio, reply_stickerReply with media
edit_text(text)Edit in place
delete()Delete for everyone
forward(to_peer) / copy(to_peer)Forward with or without an attribution header
react(emoji) / remove_reaction()Reactions
pin() / unpin() / unpin_all()Pinning
seen()Mark read
download(path=None)Save the attached file
click(button)Trigger an inline button
load_history, clear_chat, delete_chatChat-level operations
report(reason) / get_fsm_context()Reporting, FSM access

User

user.full_name
user.first_name / user.last_name
user.phone
user.mention()          # "@username" or a display name
user.is_self
await user.send_message("hi")
await user.block()
await user.unblock()

Chat

chat.id                  # full peer string
chat.title / chat.full_name
chat.is_private / is_group / is_channel
chat.mention()
await chat.send("hi")
await chat.send_photo(...)
await chat.send_action("typing")
await chat.load_history(limit=50)
await chat.leave()

Dialog & DialogsList

dialogs = await client.get_dialogs()
item = dialogs.find_by_id("987654321|2")
item = dialogs.find_by_username("bale_team")
print(item.title)

Media

if message.photo:
    print(message.photo.width, message.photo.height)
    await message.photo.download("/tmp/out.jpg")

Peer

from balexyz import Peer

peer = Peer.parse("987654321|2")
peer.kind          # "group"
peer.is_group      # True
peer.to_dict()     # {"id": 987654321, "type": 2}

Keyboards

from balexyz.keyboards import InlineKeyboardMarkup, InlineKeyboardButton

keyboard = InlineKeyboardMarkup()
keyboard.add(InlineKeyboardButton("Approve", callback_data="ok"))
keyboard.add(InlineKeyboardButton("Docs", url="https://example.com"))
keyboard.row(
    InlineKeyboardButton("1", callback_data="1"),
    InlineKeyboardButton("2", callback_data="2"),
)

doc = keyboard.to_dict()

Serialisation

Every model inherits from Serializable:

message.to_dict()
message.as_dict()      # alias
message.to_json()
message.as_json()
bale xyz 1.0.0 · MIT licensed · unofficial client © 2026 bale xyz contributors