Skip to main content

Discord channel for Bub

Project description

bub-discord

Discord channel adapter for bub.

What It Provides

  • Channel implementation: DiscordChannel (name = "discord")
  • Inbound message adaptation from Discord to Bub ChannelMessage
  • Outbound sending to Discord channels with:
    • automatic chunking at Discord's 2000-character limit
    • reply-to-latest-message behavior per session

Installation

uv pip install bub-discord

You can also install it with Bub:

bub install bub-discord@main

Configuration

DiscordChannel reads settings from environment variables with the BUB_DISCORD_ prefix.

  • BUB_DISCORD_TOKEN (required): Discord bot token
  • BUB_DISCORD_ALLOW_USERS (optional): Comma-separated allowlist of sender identifiers
    • Supports user ID, username, and global name
  • BUB_DISCORD_ALLOW_CHANNELS (optional): Comma-separated allowlist of channel IDs
  • BUB_DISCORD_COMMAND_PREFIX (optional, default: !)
  • BUB_DISCORD_PROXY (optional): HTTP proxy URL for Discord API

Runtime Behavior

  • Session ID format: discord:<channel_id>
  • Inbound messages:
    • ignores bot messages
    • ignores empty text messages
    • applies allowlist filters when configured
  • Message activation (is_active = true) when any of these is true:
    • message is in DM
    • message mentions the bot
    • content contains bub
    • content starts with <prefix>bub
    • message replies to a previous bot message
  • Command detection:
    • if content starts with <prefix>bub , that prefix is removed first
    • if remaining content starts with ,, message kind becomes command

Payload Shape

Inbound non-command messages are encoded as JSON string content, including fields like:

  • message
  • message_id
  • type
  • username
  • full_name
  • sender_id
  • date
  • channel_id
  • guild_id
  • reply_to_message (when present)

Outbound Notes

  • Uses session_id to resolve destination channel.
  • Splits long messages into multiple Discord posts.
  • Replies to the latest inbound message in the same session when possible.

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

bub_discord-0.0.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

bub_discord-0.0.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file bub_discord-0.0.1.tar.gz.

File metadata

  • Download URL: bub_discord-0.0.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bub_discord-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d442655e20d902c2a7341881f0db18df745a9c9e6c298e1742ef1806188bc885
MD5 e8d790248851d653c1378396faaa30ec
BLAKE2b-256 207d73ffe95431ce2e17ab08ab90c6d5638c9977fd23d0ce4f1319709009e1d2

See more details on using hashes here.

File details

Details for the file bub_discord-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: bub_discord-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bub_discord-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d101dbafe6b2a5cda286b0a29b132ddace720f5e22bc871d8152537e0a0e81c
MD5 022e902a42648499eb82463758fff1f6
BLAKE2b-256 8a30178ce9b0ec587d106911389db7263c25ce2a0f36dfabe7872fee3a9377dc

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