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
24
src/irc/mod.rs
Normal file
24
src/irc/mod.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//! Minimal IRC protocol layer — the "IRC library".
|
||||
//!
|
||||
//! Implements just enough of the modern IRC client protocol
|
||||
//! (<https://modern.ircdocs.horse/>) to drive a bot:
|
||||
//!
|
||||
//! * [`Message`] / [`Prefix`] — parsing of the wire format
|
||||
//! `@tags :source COMMAND params`, including IRCv3 message tags and
|
||||
//! trailing parameters ([`message`]).
|
||||
//! * [`Connection`] — a blocking TCP/TLS transport with convenience senders
|
||||
//! ([`connection`]).
|
||||
//! * Small self-contained helpers — base64 and `server-time` parsing
|
||||
//! ([`encoding`]) — so the layer stays dependency-free apart from TLS.
|
||||
//!
|
||||
//! It is deliberately self-contained, so it can grow into a small reusable IRC
|
||||
//! library independent of the bot logic in [`crate::bot`].
|
||||
#![allow(dead_code)] // Library-style module; not every helper/sender is used yet.
|
||||
|
||||
mod connection;
|
||||
mod encoding;
|
||||
mod message;
|
||||
|
||||
pub use connection::Connection;
|
||||
pub use encoding::{base64_encode, now_unix, parse_server_time};
|
||||
pub use message::{Message, Prefix};
|
||||
Loading…
Add table
Add a link
Reference in a new issue