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.1.tar.gz (11.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.1.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reasonspace_bot-0.1.1.tar.gz
  • Upload date:
  • Size: 11.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.1.1.tar.gz
Algorithm Hash digest
SHA256 76b8f0be2b9bfdd40946d5ec4671982eaff742ba2daeee9705cc064a25b293d7
MD5 662e7d93f51e5c03b133b1b435f5d7ee
BLAKE2b-256 c69d2a6501dc80ba4cbd5282439d91aba4cc520b745ab8dfd56853373fa418fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for reasonspace_bot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b09d37a44f39330be1f15e9485fe79b60718d050a484e2f6232af9519f1c6bcb
MD5 9a14f8af5ddc6cdfabbf9cccdffac19e
BLAKE2b-256 7407b7fc52ad18cab2564056329fbfa7f9b8349df5e752d56d4eeb7d517960f8

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