Discord companion bot for FicHub: recommendations, search, downloads, requests, roadmap — Socrates-style companion to the self-hosted fanfiction archive
  • Rust 99.9%
  • Shell 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
hirrolot19 5694f1d9d3
Some checks failed
CI / test (push) Failing after 2s
CI / clippy (push) Failing after 2s
CI / fmt (push) Failing after 2s
feat: add fandom browsing commands
- GET /api/fandoms and /api/fandoms/{slug} API client methods
- do_fandoms() and do_fandom(slug) dispatch functions
- Fandoms/Fandom intent parsing from natural language
- CLI subcommands: fandoms, fandom <slug>
- Discord, Telegram, Matrix, Slack, IRC, Fediverse command support
- Updated ROADMAP.md
2026-08-17 16:15:28 +02:00
.forgejo/workflows ci: GitHub + Forgejo workflows, rust-toolchain, release stub 2026-08-16 15:30:24 +02:00
.github/workflows ci: GitHub + Forgejo workflows, rust-toolchain, release stub 2026-08-16 15:30:24 +02:00
crates feat: add fandom browsing commands 2026-08-17 16:15:28 +02:00
deploy refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
docs refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
examples refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
.env.example docs: note fichub.net legacy API is not a compatible backend 2026-08-16 18:29:46 +02:00
.gitignore chore: ignore feature worktree dirs 2026-08-16 15:30:41 +02:00
ADAPTERS.md refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
Cargo.lock feat: add fandom browsing commands 2026-08-17 16:15:28 +02:00
Cargo.toml refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
LICENSE feat: fanfic-archivist Discord bot (FicHub companion) 2026-08-15 21:07:01 +02:00
PLATFORM-SETUP.md refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
README.md refactor: rename fichub-cli to fic-archivist, registry core dep, public default endpoint 2026-08-16 18:54:16 +02:00
release-plz.toml docs: release-plz config + RELEASING.md 2026-08-16 15:30:24 +02:00
ROADMAP.md feat: add fandom browsing commands 2026-08-17 16:15:28 +02:00
rust-toolchain.toml ci: GitHub + Forgejo workflows, rust-toolchain, release stub 2026-08-16 15:30:24 +02:00

fanfic-archivist

Multi-platform companion bot for FicHub, a self-hosted fanfiction archive with 107-site scraper parity, pluggable recommendations, full-text body search, an LLM "Ask the Archive", a Fic Requests board, and a Roadmap consensus arena.

The bot is a thin client over the FicHub REST API: it never touches the archive's database directly, and it shares FicHub's Redis for a transient pagination cache so !next/!prev don't hammer the DB. The same platform-neutral core drives every chat front-end — Discord, Matrix, Telegram, Slack, IRC, Mastodon/Bluesky/Piefed, and a terminal CLI.

Architecture

┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌────────────┐ ┌──────────┐
│   Discord   │ │   Matrix    │ │  Telegram   │ │    Slack   │ │    IRC   │
│  (Discord)  │ │ (matrix)    │ │ (teloxide)  │ │ (socket    │ │ (irc-rs) │
│   poise     │ │  SDK        │ │             │ │   mode)    │ │          │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └─────┬──────┘ └────┬─────┘
       │               │               │              │             │
       │  ┌────────────┴───────────────┴──────────────┴─────────────┴───┐
       │  │            archivist-core  (platform-neutral)              │
       │  │  commands · intent/LLM · pagination cache · token store    │
       │  │  do_* → PlatformMessage (render matrix per platform)        │
       │  └───────────────┬───────────────────────────┬────────────────┘
       │                  │                           │
       │   ┌──────────────▼──────────┐    ┌───────────▼──────────┐
       │   │   FicHub REST API       │    │  Redis (shared with  │
       └──▶│   (HTTP, base_url)      │    │  FicHub: cache,       │
           └─────────────────────────┘    │  tokens, link codes)  │
                                          └──────────────────────┘

Two more front-ends exist: fanfic-archivist-fediverse (Mastodon, Bluesky, Piefed listeners in one binary) and fic-archivist (terminal + a WebSocket module for a future FicHub web-chat route).

crates/
├── archivist-core/            # all business logic (the only "real" crate)
│   ├── config.rs               # FANFIC_ARCHIVIST_* env config
│   ├── api.rs                  # typed reqwest client for the REST API
│   ├── dispatch.rs             # do_* commands → PlatformMessage
│   ├── intent.rs               # free-form mention intent parsing
│   ├── cache.rs                # Redis pagination cache
│   ├── store.rs                # token store + link codes
│   └── lemmy.rs, debug.rs, ... # community monitor, LLM failure diagnosis
├── fanfic-archivist/           # Discord adapter (poise; the original bot)
├── fanfic-archivist-matrix/    # Matrix adapter
├── fanfic-archivist-telegram/  # Telegram adapter (teloxide)
├── fanfic-archivist-slack/     # Slack adapter (Socket Mode)
├── fanfic-archivist-irc/       # IRC adapter (irc-rs, TLS by default)
├── fanfic-archivist-fediverse/ # Mastodon + Bluesky + Piefed listeners
└── fic-archivist/                 # terminal CLI (+ ws module for web chat)

Prerequisites

  • Rust (stable; workspace resolver = "2", edition 2024) — https://rustup.rs
  • Redis — used for the pagination cache, token store, and link codes:
    redis-server   # or your distro package / existing FicHub Redis
    
  • A FicHub instance — the bot talks only to its REST API. Point FANFIC_ARCHIVIST_BASE_URL at it (default http://localhost:8000).
  • Ollamaoptional, only if you enable FANFIC_ARCHIVIST_LLM_ENABLED for intent classification.

Quickstart

git clone <this repo> && cd fanfic-archivist

cp .env.example .env        # then edit .env: tokens, base URL, ...
redis-server &              # or ensure Redis is already up

cargo build --workspace     # or --release
cargo test --workspace      # unit + integration tests (no services needed)

Run one adapter (each binary loads .env from its working directory):

# Discord (needs DISCORD_TOKEN)
cargo run -p fanfic-archivist

# Matrix (needs MATRIX_USERNAME/PASSWORD or MATRIX_ACCESS_TOKEN)
cargo run -p fanfic-archivist-matrix

# Telegram (needs TELEGRAM_BOT_TOKEN)
cargo run -p fanfic-archivist-telegram

# Slack (needs SLACK_BOT_TOKEN + SLACK_APP_TOKEN)
cargo run -p fanfic-archivist-slack

# IRC (sensible defaults; set FANFIC_ARCHIVIST_IRC_CHANNELS)
cargo run -p fanfic-archivist-irc

# Mastodon + Bluesky + Piefed (at least one listener must be configured)
cargo run -p fanfic-archivist-fediverse

# Terminal CLI
cargo run -p fic-archivist -- search "slow burn dramione"
cargo run -p fic-archivist -- tui                 # interactive three-pane TUI
cargo run -p fic-archivist -- --help              # full command list

For release builds add --release (or build once and run the binaries in target/release/). Adapters that are missing a required credential exit at startup with a message naming the variable.

Configuration

All env vars, grouped by crate, with defaults and REQUIRED markers, live in .env.example — copy it to .env and fill in.

  • Shared core: FANFIC_ARCHIVIST_BASE_URL, FANFIC_ARCHIVIST_REDIS_URL, page sizes, upload caps, freeform/LLM toggles, Lemmy monitor.
  • Per platform: DISCORD_TOKEN, MATRIX_*, TELEGRAM_*, SLACK_*, FANFIC_ARCHIVIST_IRC_*, MASTODON_*, BSKY_*, PIEFED_*, FANFIC_ARCHIVIST_API_TOKEN (CLI).

Documentation

Doc Contents
ADAPTERS.md Per-platform setup & operations: status table, credentials, systemd units, Redis namespaces, render matrix
PLATFORM-SETUP.md How to create bot accounts on each platform, step by step
docs/CLI-TUI.md fic-archivist subcommands, batch download, forum, TUI keybindings, REPL
docs/QUICKSTART.md 10-step run-your-own-bot walkthrough
ROADMAP.md Backlog and direction

Testing

cargo test --workspace

Unit tests cover config parsing, URL joining, credential detection, and dispatch logic — they run with no services (Redis/FicHub/Ollama) required. Start an adapter and smoke-test manually: send it a known URL or !recs in your test channel and confirm the metadata reply and pagination buttons.

Deploy

deploy/install.sh installs built binaries + systemd units to /opt/fanfic-archivist (see deploy/systemd/*.service); ADAPTERS.md has the manual systemd recipe.

License

AGPL-3.0-or-later (matches FicHub).