Refactor: Bot SDK cleanup (shared config, macro-driven handlers) #90

Closed
opened 2026-07-08 02:40:34 +00:00 by icub3d · 1 comment
Owner

Category: Refactor / simplification (bot SDK) — found in code review 2026-07-07.

  • Example bots re-implement env-override config that bot-sdk::Config already provides (welcomebot/modbot/auditbot config.rs + main.rs); modbot already drifted by hard-coding seed_hex: None. Have bots embed decentcom_bot::Config (#[serde(flatten)]) or add a Bot::from_config_with(...) path.
  • The 21 on_* handler fields are declared in 3 places (bot.rs struct Bot :64, with_config :102, struct Handlers :343) plus 21 builder methods + a 21-arm dispatch. Extend the existing handler_type! macro to generate fields, methods, and dispatch from one op↔event table (~250 lines saved).
  • Fold Bot's handler fields into the Handlers struct it owns (Bot { config, handlers }), removing the field-by-field copy in run().
  • Remove unused futures-util dep (tools/bot-sdk/Cargo.toml:20).
**Category: Refactor / simplification (bot SDK)** — found in code review 2026-07-07. - [ ] Example bots re-implement env-override config that `bot-sdk::Config` already provides (`welcomebot/modbot/auditbot config.rs` + `main.rs`); modbot already drifted by hard-coding `seed_hex: None`. Have bots embed `decentcom_bot::Config` (`#[serde(flatten)]`) or add a `Bot::from_config_with(...)` path. - [ ] The 21 `on_*` handler fields are declared in 3 places (`bot.rs` `struct Bot` :64, `with_config` :102, `struct Handlers` :343) plus 21 builder methods + a 21-arm `dispatch`. Extend the existing `handler_type!` macro to generate fields, methods, and dispatch from one op↔event table (~250 lines saved). - [ ] Fold `Bot`'s handler fields into the `Handlers` struct it owns (`Bot { config, handlers }`), removing the field-by-field copy in `run()`. - [ ] Remove unused `futures-util` dep (`tools/bot-sdk/Cargo.toml:20`).
Author
Owner

All four checklist items landed on main via b87535a (merged in #107 'refactor: cleanup stories #87-92'): bots embed decentcom_bot::Config via #[serde(flatten)] + apply_env_overrides() (modbot seed_hex drift fixed), define_handlers! generates the Handlers struct / 21 builder methods / dispatch from one table, Bot { config, handlers } folded, and futures-util removed from bot-sdk. Verified against current main — closing.

All four checklist items landed on main via b87535a (merged in #107 'refactor: cleanup stories #87-92'): bots embed `decentcom_bot::Config` via `#[serde(flatten)]` + `apply_env_overrides()` (modbot seed_hex drift fixed), `define_handlers!` generates the Handlers struct / 21 builder methods / dispatch from one table, `Bot { config, handlers }` folded, and `futures-util` removed from bot-sdk. Verified against current main — closing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
icub3d/decentcom#90
No description provided.