No description
  • Python 99%
  • Shell 1%
Find a file
the-codemancer 943c8ed05e Track Chatto v0.5.0-beta.27
Wire delta (catches up b21-b27): BREAKING - AdminInviteLinkService/invite links removed upstream (chatto #3085), replaced by AdminInvitationCodeService (single-use registration codes); wrappers and dataclass renamed accordingly (admin_*_invitation_code*, InvitationCode/InvitationCodeStatus, services.admin_invitation_codes), verified live: old endpoints 404, new 401. Additive: new account_actions.proto fetched + AccountActions/UsernameChangeAvailability + enums parsed into ViewerUser.actions; discovery ListFeatures -> list_features()/ServerFeature; RoomService GetNotice/PublishNotice/ClearNotice -> get_notice/publish_notice/clear_notice + RoomNotice; Room.created_at + show_membership_events (update_room param); account deactivation: admin_set_user_deactivated, User/AdminMember.deactivated; CreateMessage idempotency_key -> post_message(idempotency_key=...); ServerLogin.account_creation_policy; admin ServerConfig.registration with explicit update mask in admin_update_server_config; external-identity disconnect_eligibility / choose_username / invitation_required / invitation_code; realtime oneof +3 (room_notice_changed, user_account_deactivation_changed, room_membership_events_visibility_changed) dispatched via existing Bot room/user event kinds.

Verification: ruff format+check clean (27 files); mypy zero new errors vs baseline (6 pre-existing protobuf import-untyped); pytest 153 passed / 2 skipped; live GetServer round-trip + list_features against chat.chatto.run (server reports 0.5.0-beta.27); live bot integration tests pass with CHATTO_BOT_KEY (2 passed, second-user test skipped).

Bumped version 0.5.0b20 -> 0.5.0b27.
2026-10-31 08:13:13 +00:00
.beans chore: mark chattolib-uuqm completed (fixed in a39cb6d) 2026-08-31 14:34:58 +01:00
docs Track Chatto 0.5.0-beta.4 2026-09-19 23:22:20 +01:00
examples/bot Bot framework: group-aware joining + auto-join say() 2026-08-29 22:24:08 +01:00
LICENSES Relicense chattolib to MPL-2.0 (with Apache-2.0 for vendored protos) 2026-07-13 00:59:48 +01:00
proto Track Chatto v0.5.0-beta.27 2026-10-31 08:13:13 +00:00
scripts Track Chatto v0.5.0-beta.27 2026-10-31 08:13:13 +00:00
src/chattolib Track Chatto v0.5.0-beta.27 2026-10-31 08:13:13 +00:00
tests Track Chatto v0.5.0-beta.27 2026-10-31 08:13:13 +00:00
.gitignore Gitignore .env.pipy (PyPI upload token) 2026-07-14 14:21:43 +01:00
.venv Upgrade chattolib to 0.5.0a2 (Chatto v0.5.0-alpha.2) 2026-08-29 15:53:10 +01:00
AGENTS.md Track Chatto v0.5.0-beta.27 2026-10-31 08:13:13 +00:00
CLAUDE.md Fix chattolib 0.4.19 to match the released Chatto server 2026-08-04 10:30:56 +01:00
LICENSE Relicense chattolib to MPL-2.0 (with Apache-2.0 for vendored protos) 2026-07-13 00:59:48 +01:00
LICENSING.md Relicense chattolib to MPL-2.0 (with Apache-2.0 for vendored protos) 2026-07-13 00:59:48 +01:00
pyproject.toml Track Chatto v0.5.0-beta.27 2026-10-31 08:13:13 +00:00
README.md Make chattolib a bot-only library: remove normal-user access 2026-08-30 21:24:29 +01:00
REUSE.toml Relicense chattolib to MPL-2.0 (with Apache-2.0 for vendored protos) 2026-07-13 00:59:48 +01:00

chattolib

Unofficial async Python client library for the Chatto webchat API.

Chattolib versions track the Chatto server version they target. The current release targets Chatto's ConnectRPC API. Request/response traffic uses the official connectrpc Python package; the realtime channel is a binary protobuf WebSocket at /api/realtime (needs the [realtime] extra).

chattolib is a bot library. It drives bot accounts, which authenticate with a key used directly as a bearer token (no password, no /auth/login round-trip). Normal humans use the Chatto web app; you reach the API here as a bot. See the bot guide.

Install

pip install chattolib

Quick start

import asyncio
from chattolib import ChattoClient


async def main():
    # Public discovery — no auth required
    async with ChattoClient() as anon:
        profile, login = await anon.get_server()
        print(f"Chatto {profile.version}: {profile.name}")

    # Authenticated calls — a bot key is used directly as a bearer token
    async with ChattoClient(token="cht_BK_...") as client:
        me = await client.me()
        print(f"Authenticated as {me.display_name}")

        for entry in await client.list_rooms():
            if entry.room:
                print(f"  - {entry.room.name}")


asyncio.run(main())

For a full bot (event handlers, say/reply/react, presence, auto-join), use the higher-level :class:~chattolib.bot.Bot facade — see docs/bots.md.

Realtime

Install with the extra:

pip install 'chattolib[realtime]'

Then stream live events:

from chattolib import stream_events

async with ChattoClient(token="cht_BK_...") as client:
    async for event in stream_events(client):
        print(event.kind, event.actor_id, event.payload)

event.kind names the protobuf oneof case (message_posted, reaction_added, presence_changed, notification_created, …). event.payload is the concrete protobuf sub-message — access its fields directly (e.g. event.payload.room_id). Realtime events are invalidation signals; use the corresponding Connect RPC (GetRoomEventsAround, GetNotification, GetUser, …) to hydrate the referenced resource.

Escape hatch

ChattoClient.services exposes the underlying connectrpc service clients directly (one per Chatto service), for anything the Pythonic wrappers don't yet cover. For example:

from chattolib._pb.chatto.api.v1 import messages_pb2

resp = await client.services.messages.get_message(
    messages_pb2.GetMessageRequest(room_id=..., event_id=...)
)

License

  • chattolib's own code is licensed under MPL-2.0 (Mozilla Public License 2.0) — a weak, file-level copyleft. You can use, distribute, and embed chattolib in commercial or proprietary software; modifications to the library's own files must be released under MPL-2.0.
  • Vendored Chatto protobuf definitions under proto/chatto/** and the generated bindings under src/chattolib/_pb/chatto/** are Apache-2.0, matching upstream chattocorp/chatto.
  • Vendored buf.validate material is Apache-2.0 (from bufbuild/protovalidate).

See LICENSING.md for the full picture and REUSE.toml for the machine-readable licence map.

Note: chattolib versions 0.0.1 through 0.4.9 were released under MIT. Those releases remain MIT-licensed forever on PyPI; the MPL-2.0 relicence applies to newly published releases only.