METADATA 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Metadata-Version: 2.4
  2. Name: chattolib
  3. Version: 0.4.20.post1
  4. Summary: Async Python client library for the Chatto webchat Connect API
  5. Author-email: Felix <chatto@f3l1x.it>
  6. License-Expression: MPL-2.0 AND Apache-2.0
  7. Project-URL: Homepage, https://chat.chatto.run
  8. Keywords: chatto,connect,connectrpc,async,webchat,client
  9. Classifier: Development Status :: 3 - Alpha
  10. Classifier: Intended Audience :: Developers
  11. Classifier: Programming Language :: Python :: 3
  12. Classifier: Programming Language :: Python :: 3.11
  13. Classifier: Programming Language :: Python :: 3.12
  14. Classifier: Programming Language :: Python :: 3.13
  15. Classifier: Topic :: Communications :: Chat
  16. Classifier: Framework :: AsyncIO
  17. Requires-Python: >=3.11
  18. Description-Content-Type: text/markdown
  19. License-File: LICENSE
  20. License-File: LICENSES/Apache-2.0.txt
  21. License-File: LICENSES/MPL-2.0.txt
  22. Requires-Dist: connectrpc>=0.11
  23. Requires-Dist: protobuf>=5.28
  24. Requires-Dist: httpx>=0.27
  25. Provides-Extra: realtime
  26. Requires-Dist: websockets>=13.0; extra == "realtime"
  27. Provides-Extra: dev
  28. Requires-Dist: pytest>=8.0; extra == "dev"
  29. Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
  30. Requires-Dist: respx>=0.22; extra == "dev"
  31. Requires-Dist: ruff>=0.8; extra == "dev"
  32. Requires-Dist: mypy>=1.13; extra == "dev"
  33. Requires-Dist: types-protobuf>=5.28; extra == "dev"
  34. Requires-Dist: unasync>=0.6; extra == "dev"
  35. Dynamic: license-file
  36. # chattolib
  37. **Unofficial** async Python client library for the [Chatto](https://chat.chatto.run) webchat API.
  38. > Chattolib versions track the Chatto server version they target. The current
  39. > release targets Chatto's ConnectRPC API. Request/response traffic uses the
  40. > official [`connectrpc`](https://pypi.org/project/connectrpc/) Python
  41. > package; the realtime channel is a binary protobuf WebSocket at
  42. > `/api/realtime` (needs the ``[realtime]`` extra).
  43. ## Install
  44. ```bash
  45. pip install chattolib
  46. ```
  47. ## Quick start
  48. ```python
  49. import asyncio
  50. from chattolib import ChattoClient
  51. async def main():
  52. # Public discovery — no auth required
  53. async with ChattoClient() as anon:
  54. profile, login = await anon.get_server()
  55. print(f"Chatto {profile.version}: {profile.name}")
  56. # Authenticated calls
  57. async with await ChattoClient.login("username", "password") as client:
  58. me = await client.me()
  59. print(f"Logged in as {me.display_name}")
  60. for entry in await client.list_rooms():
  61. if entry.room:
  62. print(f" - {entry.room.name}")
  63. asyncio.run(main())
  64. ```
  65. ## Realtime
  66. Install with the extra:
  67. ```bash
  68. pip install 'chattolib[realtime]'
  69. ```
  70. Then stream live events:
  71. ```python
  72. from chattolib import stream_events
  73. async with await ChattoClient.login("username", "password") as client:
  74. async for event in stream_events(client):
  75. print(event.kind, event.actor_id, event.payload)
  76. ```
  77. `event.kind` names the protobuf ``oneof`` case (`message_posted`,
  78. `reaction_added`, `presence_changed`, `notification_created`, …).
  79. `event.payload` is the concrete protobuf sub-message — access its fields
  80. directly (e.g. `event.payload.room_id`). Realtime events are invalidation
  81. signals; use the corresponding Connect RPC (`GetRoomEventsAround`,
  82. `GetNotification`, `GetUser`, …) to hydrate the referenced resource.
  83. ## Escape hatch
  84. `ChattoClient.services` exposes the underlying `connectrpc` service clients
  85. directly (one per Chatto service), for anything the Pythonic wrappers don't
  86. yet cover. For example:
  87. ```python
  88. from chattolib._pb.chatto.api.v1 import messages_pb2
  89. resp = await client.services.messages.get_message(
  90. messages_pb2.GetMessageRequest(room_id=..., event_id=...)
  91. )
  92. ```
  93. ## License
  94. - chattolib's own code is licensed under **MPL-2.0** (Mozilla Public License
  95. 2.0) — a weak, file-level copyleft. You can use, distribute, and embed
  96. chattolib in commercial or proprietary software; modifications to the
  97. library's own files must be released under MPL-2.0.
  98. - Vendored Chatto protobuf definitions under `proto/chatto/**` and the
  99. generated bindings under `src/chattolib/_pb/chatto/**` are **Apache-2.0**,
  100. matching upstream [`chattocorp/chatto`](https://github.com/chattocorp/chatto).
  101. - Vendored `buf.validate` material is Apache-2.0 (from
  102. [`bufbuild/protovalidate`](https://github.com/bufbuild/protovalidate)).
  103. See [LICENSING.md](LICENSING.md) for the full picture and
  104. [REUSE.toml](REUSE.toml) for the machine-readable licence map.
  105. Note: chattolib versions **0.0.1 through 0.4.9** were released under **MIT**.
  106. Those releases remain MIT-licensed forever on PyPI; the MPL-2.0 relicence
  107. applies to newly published releases only.