# okbuddyhololive/polkabot architecture

> Architecture diagram of the GitHub repository okbuddyhololive/polkabot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/okbuddyhololive/polkabot
- Repository: https://github.com/okbuddyhololive/polkabot

## Overview

Polkabot is a Discord bot that collects server messages, generates Markov-chain text for impersonation, and provides related commands for opting out, statistics, and media links. The main workflow is a Discord message entering the collection listener, being stored through the message manager, then later retrieved and generated into a webhook message by an impersonation command. Other cogs handle consent, statistics, and media discovery. The graph reflects the shown setup and excerpts; some cogs and configuration details were not sampled, so their internal relationships are omitted.

Main entry points: [`modules/chain.py`](https://github.com/okbuddyhololive/polkabot/blob/main/modules/chain.py) (Message manager), [`bot.py`](https://github.com/okbuddyhololive/polkabot/blob/main/bot.py) (Bot setup), [`cogs/impersonation.py`](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/impersonation.py) (Impersonation), [`cogs/other.py`](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/other.py) (Media commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bot["Bot setup<br/>[bot.py]"]
  node_events["Event handling<br/>[events.py]"]
  node_help["Help command<br/>[help.py]"]
  node_cooldown["Cooldown checks<br/>[cooldown.py]"]
end

subgraph group_messages["Message data"]
  node_message_manager["Message manager<br/>[chain.py]"]
  node_message_records[("Message records<br/>[chain.py]")]
  node_optout_records[("Opt-out records<br/>[opting.py]")]
  node_link_records[("Banned links<br/>[other.py]")]
end

subgraph group_commands["User commands"]
  node_impersonation["Impersonation<br/>[impersonation.py]"]
  node_opting["Opt-in controls<br/>[opting.py]"]
  node_statistics["Message statistics<br/>[statistics.py]"]
  node_media["Media commands<br/>[other.py]"]
end

subgraph group_delivery["Webhook delivery"]
  node_webhook_manager["Webhook manager<br/>[webhooks.py]"]
  node_webhook_records[("Webhook records<br/>[webhooks.py]")]
end

node_discord_user(("Discord user"))
node_discord{{"Discord platform"}}

node_discord_user -->|"sends commands"| node_discord
node_discord -->|"delivers events"| node_bot
node_bot -->|"loads cog"| node_events
node_bot -->|"configures help"| node_help
node_bot -->|"applies cooldowns"| node_cooldown
node_bot -->|"runs bot"| node_discord
node_discord -->|"delivers messages"| node_impersonation
node_impersonation -->|"adds and retrieves"| node_message_manager
node_impersonation -->|"gets or creates"| node_webhook_manager
node_impersonation -->|"checks users"| node_optout_records
node_message_manager -->|"reads and writes"| node_message_records
node_message_manager -->|"generates text"| node_discord
node_webhook_manager -->|"reads and writes"| node_webhook_records
node_webhook_manager -->|"creates webhook"| node_discord
node_opting -->|"deletes user data"| node_message_manager
node_opting -->|"updates consent"| node_optout_records
node_statistics -->|"queries messages"| node_message_manager
node_media -->|"queries links"| node_message_manager
node_media -->|"reads and records"| node_link_records
node_impersonation -->|"sends impersonation"| node_discord
node_statistics -->|"replies with results"| node_discord
node_media -->|"replies with media"| node_discord

click node_bot "https://github.com/okbuddyhololive/polkabot/blob/main/bot.py"
click node_events "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/events.py"
click node_help "https://github.com/okbuddyhololive/polkabot/blob/main/modules/help.py"
click node_cooldown "https://github.com/okbuddyhololive/polkabot/blob/main/modules/cooldown.py"
click node_impersonation "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/impersonation.py"
click node_opting "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/opting.py"
click node_statistics "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/statistics.py"
click node_media "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/other.py"
click node_message_manager "https://github.com/okbuddyhololive/polkabot/blob/main/modules/chain.py"
click node_message_records "https://github.com/okbuddyhololive/polkabot/blob/main/modules/chain.py"
click node_optout_records "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/opting.py"
click node_link_records "https://github.com/okbuddyhololive/polkabot/blob/main/cogs/other.py"
click node_webhook_manager "https://github.com/okbuddyhololive/polkabot/blob/main/modules/webhooks.py"
click node_webhook_records "https://github.com/okbuddyhololive/polkabot/blob/main/modules/webhooks.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bot,node_events,node_help,node_cooldown,node_discord_user toneBlue
class node_message_manager,node_message_records,node_optout_records,node_link_records toneAmber
class node_impersonation,node_opting,node_statistics,node_media toneMint
class node_webhook_manager,node_webhook_records toneRose
class node_discord toneIndigo
```

## Components

### Bot runtime

- [Bot setup](https://github.com/okbuddyhololive/polkabot/blob/main/bot.py): `bot.py`
- [Event handling](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/events.py): `cogs/events.py`
- [Help command](https://github.com/okbuddyhololive/polkabot/blob/main/modules/help.py): `modules/help.py`
- [Cooldown checks](https://github.com/okbuddyhololive/polkabot/blob/main/modules/cooldown.py): `modules/cooldown.py`

### Message data

- [Message manager](https://github.com/okbuddyhololive/polkabot/blob/main/modules/chain.py): `modules/chain.py`
- [Message records](https://github.com/okbuddyhololive/polkabot/blob/main/modules/chain.py): `modules/chain.py`
- [Opt-out records](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/opting.py): `cogs/opting.py`
- [Banned links](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/other.py): `cogs/other.py`

### User commands

- [Impersonation](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/impersonation.py): `cogs/impersonation.py`
- [Opt-in controls](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/opting.py): `cogs/opting.py`
- [Message statistics](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/statistics.py): `cogs/statistics.py`
- [Media commands](https://github.com/okbuddyhololive/polkabot/blob/main/cogs/other.py): `cogs/other.py`

### Webhook delivery

- [Webhook manager](https://github.com/okbuddyhololive/polkabot/blob/main/modules/webhooks.py): `modules/webhooks.py`
- [Webhook records](https://github.com/okbuddyhololive/polkabot/blob/main/modules/webhooks.py): `modules/webhooks.py`

### Other components

- **Discord user**
- **Discord platform**

## Connections

- Discord user → Discord platform: sends commands (evidence: `README.md`)
- Discord platform → Bot setup: delivers events (evidence: `bot.py`)
- Bot setup → Event handling: loads cog (evidence: `bot.py`)
- Bot setup → Help command: configures help (evidence: `bot.py`)
- Bot setup → Cooldown checks: applies cooldowns (evidence: `bot.py`)
- Bot setup → Discord platform: runs bot (evidence: `bot.py`)
- Discord platform → Impersonation: delivers messages (evidence: `cogs/impersonation.py`)
- Impersonation → Message manager: adds and retrieves (evidence: `cogs/impersonation.py`)
- Impersonation → Webhook manager: gets or creates (evidence: `cogs/impersonation.py`)
- Impersonation → Opt-out records: checks users (evidence: `cogs/impersonation.py`)
- Message manager → Message records: reads and writes (evidence: `modules/chain.py`)
- Message manager → Discord platform: generates text (evidence: `modules/chain.py`)
- Webhook manager → Webhook records: reads and writes (evidence: `modules/webhooks.py`)
- Webhook manager → Discord platform: creates webhook (evidence: `modules/webhooks.py`)
- Opt-in controls → Message manager: deletes user data (evidence: `cogs/opting.py`)
- Opt-in controls → Opt-out records: updates consent (evidence: `cogs/opting.py`)
- Message statistics → Message manager: queries messages (evidence: `cogs/statistics.py`)
- Media commands → Message manager: queries links (evidence: `cogs/other.py`)
- Media commands → Banned links: reads and records (evidence: `cogs/other.py`)
- Impersonation → Discord platform: sends impersonation (evidence: `cogs/impersonation.py`)
- Message statistics → Discord platform: replies with results (evidence: `cogs/statistics.py`)
- Media commands → Discord platform: replies with media (evidence: `cogs/other.py`)
