AsyncClient is the core async client for talking to the Zulip server.
from bot_sdk import AsyncClient
client = AsyncClient(
email: str | None = None,
api_key: str | None = None,
config_file: str | None = None,
verbose: bool = False,
retry_on_errors: bool = True,
site: str | None = None,
client: str | None = None,
cert_bundle: str | None = None,
insecure: bool | None = None,
client_cert: str | None = None,
client_cert_key: str | None = None,
)
.zuliprc (default ~/.zuliprc)[api]
email=bot@example.com
key=your-api-key-here
site=https://your-zulip-server.com
UserProfileResponseSendMessageResponseRegisterResponseEventsResponseSubscriptionsResponseasync with AsyncClient() as client:
profile = await client.get_profile()
print(profile.full_name)
client = AsyncClient()
try:
await client.ensure_session()
# ... use client ...
finally:
await client.aclose()
from bot_sdk import BotRunner, BaseBot
runner = BotRunner(
lambda c: MyBot(c),
client_kwargs={"config_file": "~/.zuliprc"}
)
async with runner:
await runner.run_forever()
ZulipError: Base exceptionConfigNotFoundError: Config file missingMissingURLError: Missing Zulip server URLUnrecoverableNetworkError: Cannot connect to serverawait async methods.aclose() or async with.retry_on_errors=False.insecure=True in production.