Официальный Python SDK для платформы ботов Reason Space (decorator-framework + REST-клиент + HMAC-verify webhook receiver).
Project description
reasonspace-bot
Официальный Python SDK для платформы ботов Reason Space: decorator-framework для приёма webhook-событий + async REST-клиент + проверка HMAC-подписи.
pip install reasonspace-bot
Minimal bot
from reasonspace_bot import Bot, MessageCreatedEvent
bot = Bot() # читает BOT_TOKEN + WEBHOOK_SECRET из env
@bot.on("message.created")
async def on_message(event: MessageCreatedEvent) -> None:
if event.author_is_bot:
return
if event.plain_command == "/ping":
await bot.send_message(event.channel_id, "🏓 pong", space_id=event.space_id)
if __name__ == "__main__":
bot.run(port=8765)
Env
| Var | Назначение |
|---|---|
BOT_TOKEN |
bot_<48hex> — токен бота (обязателен) |
WEBHOOK_SECRET |
секрет вебхука; пусто = dev-mode без verify (обязателен в prod) |
REASONSPACE_API |
базовый URL API (по умолчанию https://api.reasonspace.ru) |
Что внутри
Bot—@bot.on("<event.type>"), встроенный ASGI-appbot.app(/webhook+/, авто HMAC-verify, дедуп поX-Reasonspace-Delivery, упавший хендлер не валит доставку).BotClient—send_message,list_messages,add_reaction,delete_message,list_members,list_roles,kick_member,mute_member,voice_join,voice_overview. УважаетRetry-After.- Типизированные события:
MessageCreatedEvent,MemberJoinedEvent,VoiceJoinedEvent, … Неизвестный type → genericBotEvent(старый код не падает). verify_signature(secret, body, header)— если делаете свой receiver.
Prod
gunicorn bot:bot.app --workers 4 --worker-class uvicorn.workers.UvicornWorker
Документация: https://docs.reasonspace.ru
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reasonspace_bot-0.1.0.tar.gz.
File metadata
- Download URL: reasonspace_bot-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0ffb920a3a9747510a8cf320e898fe84dc61cb329ba6aa60fa6b7f6d7102161
|
|
| MD5 |
86c1d4169407093e29efdb0f594da50a
|
|
| BLAKE2b-256 |
d4214417e5ccaf3eb7406b6c7e481ef2b17a0519f9df5504edb2314c49bba1bd
|
File details
Details for the file reasonspace_bot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: reasonspace_bot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f2b5795000e763a4452e0b071cdce504291819f23993783d516a33f0bb3042
|
|
| MD5 |
8ba2d4c164960c5cb17451ec5632215f
|
|
| BLAKE2b-256 |
6cff66345325f4f8ad05e98b6d207a01a1e2a4122b74927b8ebe9b39829c0617
|