Skip to main content

Официальный 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-app bot.app (/webhook + /, авто HMAC-verify, дедуп по X-Reasonspace-Delivery, упавший хендлер не валит доставку).
  • BotClientsend_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 → generic BotEvent (старый код не падает).
  • verify_signature(secret, body, header) — если делаете свой receiver.

Prod

gunicorn bot:bot.app --workers 4 --worker-class uvicorn.workers.UvicornWorker

Документация: https://docs.reasonspace.ru

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reasonspace_bot-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reasonspace_bot-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

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

Hashes for reasonspace_bot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a0ffb920a3a9747510a8cf320e898fe84dc61cb329ba6aa60fa6b7f6d7102161
MD5 86c1d4169407093e29efdb0f594da50a
BLAKE2b-256 d4214417e5ccaf3eb7406b6c7e481ef2b17a0519f9df5504edb2314c49bba1bd

See more details on using hashes here.

File details

Details for the file reasonspace_bot-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for reasonspace_bot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1f2b5795000e763a4452e0b071cdce504291819f23993783d516a33f0bb3042
MD5 8ba2d4c164960c5cb17451ec5632215f
BLAKE2b-256 6cff66345325f4f8ad05e98b6d207a01a1e2a4122b74927b8ebe9b39829c0617

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page