Skip to content

Errors

TDLib answers with objects. A successful result is truthy; an Error is falsy — so you can write if not chat after getChat.

chat = await client.getChat(chat_id=chat_id)
if not chat:
    print(chat.message, chat.code)
    return

Raise StopHandlers from a handler to skip the rest of the chain. AuthorizationError is for login failures.

Flood wait: Error.limited_seconds is the retry delay in seconds (0 unless code == 429).

result = await client.sendMessage(...)
if not result:
    wait = result.limited_seconds