Restructure into a library crate with modular bot and irc
Split the single-binary crate into a reusable `rustbot` library (src/lib.rs)
plus a thin supervisor binary. The monolithic irc.rs and bot.rs become module
folders:
irc/ message (wire parsing), connection (TCP/TLS transport), encoding
bot/ mod (state + event loop), caps (IRCv3 cap negotiation + SASL),
commands (message routing + command table)
config Config + layered loading, moved out of main.rs and bot.rs
main.rs is now just the per-network connect/reconnect supervisor over the
library API. Unit tests move out of the source files into tests/ integration
tests (config.rs, protocol.rs) that drive the public surface — prefix parsing
is now covered through Message::parse, and config layering through the new
public config::parse_str. Behavior is unchanged; no new dependencies.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
e7e805cb87
commit
eb3b8fec40
16 changed files with 1189 additions and 1116 deletions
23
src/lib.rs
Normal file
23
src/lib.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//! rustbot — a small, modular IRC bot, split into a reusable library (this
|
||||
//! crate) and a thin binary (`src/main.rs`).
|
||||
//!
|
||||
//! Modules:
|
||||
//! * [`irc`] — protocol + transport (the "IRC library"): message parsing,
|
||||
//! IRCv3 tags, and a blocking TCP/TLS [`irc::Connection`].
|
||||
//! * [`bot`] — behavior: registration, capability negotiation, the event
|
||||
//! loop, and commands, driving one [`irc::Connection`].
|
||||
//! * [`config`] — the layered [`config::Config`] and how it is loaded from a
|
||||
//! file (with optional `[network]` sections) and environment.
|
||||
//!
|
||||
//! The binary adds only a per-network connect/reconnect supervisor on top, so
|
||||
//! the whole bot is exercisable — and reusable — through this library's API.
|
||||
|
||||
pub mod bot;
|
||||
pub mod config;
|
||||
pub mod irc;
|
||||
|
||||
/// Tiny stderr logger shared by the library and the binary. Swap for the
|
||||
/// `log`/`tracing` crates if you outgrow it.
|
||||
pub fn log(msg: &str) {
|
||||
eprintln!("[rustbot] {msg}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue