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.2.0.tar.gz (12.1 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.2.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file reasonspace_bot-0.2.0.tar.gz.

File metadata

  • Download URL: reasonspace_bot-0.2.0.tar.gz
  • Upload date:
  • Size: 12.1 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.2.0.tar.gz
Algorithm Hash digest
SHA256 831061f3170a01a751ec58cd528b42de10ddd4322b882e697272641c264592cb
MD5 edd45893c6d98a8c9e228652fe9a67d7
BLAKE2b-256 f3d72e548413613e141207589d8569e064a8c5bcca0d417799e04b8e0b7951ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for reasonspace_bot-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98ca20ddba80b7c17aeafe4a392548d4bda1b643c7e3a09fb2c31506a4e004b7
MD5 a3708e72709526c68863274ebb6977a8
BLAKE2b-256 f9d5fb8efccff0b476a1bd0ecec76c7285452c7cd8b7610314245e2ae58c0fc3

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