Enums & errors
The small vocabulary of the library — and how failures surface.
CallMode
| Name | Value | Meaning |
|---|---|---|
CallMode.GROUP | 2 | Conference bound to a chat |
CallMode.MULTI_PEER | 3 | Link-based room |
CallMode.LIVE | 4 | Broadcast |
CallRecordQuality
Accepted by start_call_recording(quality=…) as a name or raw int.
ChatType
| Name | Value | Helpers |
|---|---|---|
ChatType.USER | 1 | is_private |
ChatType.GROUP | 2 | is_group |
ChatType.CHANNEL | 3 | is_channel |
ChatType.BOT | 4 | — |
ChatType.SUPERGROUP | 5 | is_group |
ChatType.THREAD | 6 | — |
ChatAction
Typing-style indicators: typing, uploading_photo, recording_video, and friends.
Exception hierarchy
BaleError # base for everything
├── ClientStateError # used before connecting, or no session
├── SessionError # session string / cookie extraction failed
├── TransportError # socket or HTTP layer failed
└── RpcError # server said no
├── AuthError # login rejected
└── FloodWait # rate limited (has .seconds)
BotApiError # separate: tapi.bale.ai returned ok=false
| Exception | Attributes | Typical cause |
|---|---|---|
RpcError | code, message, reason, details | Any application-level failure |
AuthError | same, plus the auth step | Wrong code, expired session, no JWT in the response |
FloodWait | seconds | Too many requests — sleep and retry |
BotApiError | code, description, method | Bot API ok: false |
ClientStateError | — | Calling RPC before start() |
Catching correctly
from balexyz import BaleError, FloodWait, RpcError
try:
await client.send_message("987654321|1", "hi")
except FloodWait as exc:
await asyncio.sleep(exc.seconds)
await client.send_message("987654321|1", "hi")
except RpcError as exc:
log.warning("rpc failed: code=%s reason=%s", exc.code, exc.reason)
except BaleError:
log.exception("transport or state problem")
Order matters.
FloodWait and AuthError both subclass
RpcError, so catch the specific ones first. Catching
BaleError alone will also swallow programming mistakes like
using a closed client.
bale xyz 1.0.0 · MIT licensed · unofficial client
© 2026 bale xyz contributors