METADATA 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. Metadata-Version: 2.4
  2. Name: chattolib
  3. Version: 0.4.19.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. Dynamic: license-file
  34. # chattolib
  35. **Unofficial** async Python client library for the [Chatto](https://chat.chatto.run) webchat API.
  36. > Chattolib versions track the Chatto server version they target. The current
  37. > release targets Chatto's ConnectRPC API. Request/response traffic uses the
  38. > official [`connectrpc`](https://pypi.org/project/connectrpc/) Python
  39. > package; the realtime channel is a binary protobuf WebSocket at
  40. > `/api/realtime` (needs the ``[realtime]`` extra).
  41. ## Install
  42. ```bash
  43. pip install chattolib
  44. ```
  45. ## Quick start
  46. ```python
  47. import asyncio
  48. from chattolib import ChattoClient
  49. async def main():
  50. # Public discovery — no auth required
  51. async with ChattoClient() as anon:
  52. profile, login = await anon.get_server()
  53. print(f"Chatto {profile.version}: {profile.name}")
  54. # Authenticated calls
  55. async with await ChattoClient.login("username", "password") as client:
  56. me = await client.me()
  57. print(f"Logged in as {me.display_name}")
  58. for entry in await client.list_rooms():
  59. if entry.room:
  60. print(f" - {entry.room.name}")
  61. asyncio.run(main())
  62. ```
  63. ## Realtime
  64. Install with the extra:
  65. ```bash
  66. pip install 'chattolib[realtime]'
  67. ```
  68. Then stream live events:
  69. ```python
  70. from chattolib import stream_events
  71. async with await ChattoClient.login("username", "password") as client:
  72. async for event in stream_events(client):
  73. print(event.kind, event.actor_id, event.payload)
  74. ```
  75. `event.kind` names the protobuf ``oneof`` case (`message_posted`,
  76. `reaction_added`, `presence_changed`, `notification_created`, …).
  77. `event.payload` is the concrete protobuf sub-message — access its fields
  78. directly (e.g. `event.payload.room_id`). Realtime events are invalidation
  79. signals; use the corresponding Connect RPC (`GetRoomEventsAround`,
  80. `GetNotification`, `GetUser`, …) to hydrate the referenced resource.
  81. ## Escape hatch
  82. `ChattoClient.services` exposes the underlying `connectrpc` service clients
  83. directly (one per Chatto service), for anything the Pythonic wrappers don't
  84. yet cover. For example:
  85. ```python
  86. from chattolib._pb.chatto.api.v1 import messages_pb2
  87. resp = await client.services.messages.get_message(
  88. messages_pb2.GetMessageRequest(room_id=..., event_id=...)
  89. )
  90. ```
  91. ## License
  92. - chattolib's own code is licensed under **MPL-2.0** (Mozilla Public License
  93. 2.0) — a weak, file-level copyleft. You can use, distribute, and embed
  94. chattolib in commercial or proprietary software; modifications to the
  95. library's own files must be released under MPL-2.0.
  96. - Vendored Chatto protobuf definitions under `proto/chatto/**` and the
  97. generated bindings under `src/chattolib/_pb/chatto/**` are **Apache-2.0**,
  98. matching upstream [`chattocorp/chatto`](https://github.com/chattocorp/chatto).
  99. - Vendored `buf.validate` material is Apache-2.0 (from
  100. [`bufbuild/protovalidate`](https://github.com/bufbuild/protovalidate)).
  101. See [LICENSING.md](LICENSING.md) for the full picture and
  102. [REUSE.toml](REUSE.toml) for the machine-readable licence map.
  103. Note: chattolib versions **0.0.1 through 0.4.9** were released under **MIT**.
  104. Those releases remain MIT-licensed forever on PyPI; the MPL-2.0 relicence
  105. applies to newly published releases only.