Harden bot: line cap, send throttle, panic isolation, verbose flag, weather cache, tests

This commit is contained in:
Jean Chevronnet 2026-07-29 18:46:10 +00:00
parent 1c320ad0c3
commit 9325150315
7 changed files with 165 additions and 10 deletions

View file

@ -14,6 +14,7 @@ pub struct Config {
pub realname: String,
pub channels: Vec<String>,
pub command_prefix: String,
pub verbose: bool,
pub password: Option<String>,
pub sasl_user: Option<String>,
pub sasl_pass: Option<String>,
@ -31,6 +32,7 @@ impl Default for Config {
realname: "rubot".to_string(),
channels: vec!["#devs".to_string()],
command_prefix: "!".to_string(),
verbose: true,
password: None,
sasl_user: None,
sasl_pass: None,
@ -146,6 +148,7 @@ fn apply_kv(c: &mut Config, key: &str, value: &str, where_: &str) {
"realname" => c.realname = value.to_string(),
"channels" => c.channels = split_list(value),
"prefix" | "command_prefix" => c.command_prefix = value.to_string(),
"verbose" => c.verbose = parse_bool(value),
"password" => c.password = (!value.is_empty()).then(|| value.to_string()),
"sasl_user" => c.sasl_user = (!value.is_empty()).then(|| value.to_string()),
"sasl_pass" => c.sasl_pass = (!value.is_empty()).then(|| value.to_string()),
@ -194,6 +197,9 @@ fn apply_env(c: &mut Config) {
if let Ok(v) = std::env::var("IRC_PREFIX") {
c.command_prefix = v;
}
if let Ok(v) = std::env::var("IRC_VERBOSE") {
c.verbose = parse_bool(&v);
}
if let Ok(v) = std::env::var("IRC_PASSWORD") {
c.password = Some(v);
}