Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Core command logic — platform-neutral.

Every command the bot exposes is implemented here as a do_* function returning a PlatformMessage. Poise command wrappers (Discord) and the intent dispatcher (free-form mentions) call the SAME functions, so there is exactly one implementation of each command’s behavior. This is also the generalization seam for future platforms (Telegram/Matrix/Slack/…): a new adapter renders PlatformMessage natively and gets every command for free.

Structs§

CoreCtx
Shared state every do_* needs (subset of commands::Data; kept platform-free — no Discord types).

Functions§

do_ask
ask core — natural-language search.
do_body
body core — full-text body search.
do_bookmark
bookmark core (auth, ephemeral on Discord).
do_download
download core — links (or lazy convert) for a URL.
do_forum_categories
forum categories core — visible categories + topic counts (auth).
do_forum_create
forum new core — create a topic + OP post (auth).
do_forum_follow
forum follow core — toggle follow on a topic (auth).
do_forum_mark_read
forum read core — mark a topic read (auth). last_read_post_id defaults to the topic’s newest post when None.
do_forum_reply
forum reply core — reply to a topic, optionally quoting a post (auth).
do_forum_search
forum search core — full-text search over topics + posts (auth).
do_forum_topic
forum show core — topic detail as numbered posts (auth). Accepts a numeric topic id or a canonical slug ({slugified-title}-{id}).
do_forum_topics
forum topics core — topic list for a category, cursor-paginated (auth).
do_help
help core — grounded answer from the FicHub docs RAG (/api/docs/ask).
do_kudos
kudos core — kudos count for a URL.
do_metadata
metadata core — metadata embed for a URL (auto-URL / context menu / mention).
do_quote
quote core — metadata + body snippet for a URL.
do_recs
recs core (personalized recommendations, auth).
do_roll
roll core — random pick from personal recs.
do_search
search core. user_id is the platform user id (used for the pagination session pointer + search log). interp is an optional “interpreted as” header shown to the user (free-form mentions set it; /search leaves None).
render_ask_results
Render an /ask response (results + translation metadata).
render_forum_categories
Pure renderer for category rows (extracted for tests + TUI reuse).
render_forum_search
Pure renderer for forum search results (extracted for tests + TUI reuse).
render_forum_topic_detail
Pure renderer for a topic detail (extracted for tests + TUI reuse).
render_forum_topic_list
Pure renderer for a topic list (extracted for tests + TUI reuse).
render_recs
Shared recs renderer (recs/fresh/gems/liked/roll).
render_search_results
Shared search-results renderer (used by search/body/fallback).
run_search_impl
The actual search execution (with cache + searchlog). Extracted so the intent fallback can reuse the same cache/analytics path.