config: >rehash command to reload rustbot.conf live (channels/nick/prefix/verbose/modules) without a restart
All checks were successful
ci / check (push) Successful in 47s
All checks were successful
ci / check (push) Successful in 47s
This commit is contained in:
parent
6af92c1217
commit
3c2154bbc1
7 changed files with 226 additions and 20 deletions
49
tests/bot.rs
49
tests/bot.rs
|
|
@ -76,3 +76,52 @@ fn ignores_own_echoed_message() {
|
|||
let out = run(":rubot!r@h PRIVMSG #chan :!ping\r\n");
|
||||
assert!(!out.contains(":pong"), "{out}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rehash_applies_channel_nick_and_prefix() {
|
||||
let output = Arc::new(Mutex::new(Vec::new()));
|
||||
let mock = Mock {
|
||||
input: Cursor::new(Vec::new()),
|
||||
output: output.clone(),
|
||||
};
|
||||
let conn = Connection::from_stream(mock);
|
||||
let cfg = Config {
|
||||
name: "testnet".to_string(),
|
||||
channels: vec!["#a".to_string(), "#keep".to_string()],
|
||||
..Config::default()
|
||||
};
|
||||
let mut bot = Bot::new(cfg, conn);
|
||||
|
||||
let new = Config {
|
||||
name: "testnet".to_string(),
|
||||
channels: vec!["#keep".to_string(), "#b".to_string()],
|
||||
command_prefix: ">".to_string(),
|
||||
nick: "rubot2".to_string(),
|
||||
..Config::default()
|
||||
};
|
||||
let summary = bot.apply_config(new).unwrap();
|
||||
|
||||
let out = String::from_utf8_lossy(&output.lock().unwrap()).into_owned();
|
||||
assert!(out.contains("JOIN #b"), "{out}");
|
||||
assert!(out.contains("PART #a"), "{out}");
|
||||
assert!(!out.contains("PART #keep"), "{out}");
|
||||
assert!(out.contains("NICK rubot2"), "{out}");
|
||||
assert!(
|
||||
summary.contains("+#b") && summary.contains("-#a"),
|
||||
"{summary}"
|
||||
);
|
||||
assert!(
|
||||
summary.contains("prefix") && summary.contains("nick"),
|
||||
"{summary}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rehash_command_requires_admin() {
|
||||
// no admin configured -> ignored (default prefix is !)
|
||||
let out = run(":alice!a@h PRIVMSG #chan :!rehash\r\n");
|
||||
assert!(
|
||||
!out.contains("rehash:"),
|
||||
"unauthorized rehash replied: {out}"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,3 +48,13 @@ fn comments_and_blanks_are_ignored() {
|
|||
assert_eq!(cfgs.len(), 1);
|
||||
assert_eq!(cfgs[0].server, "irc.tchatou.fr");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admin_list_is_parsed_and_inherited() {
|
||||
let cfgs = parse_str("admin = reverse, alice\nwebchat = https://w/\n[net]\nserver = x\n");
|
||||
assert_eq!(
|
||||
cfgs[0].admin,
|
||||
vec!["reverse".to_string(), "alice".to_string()]
|
||||
);
|
||||
assert_eq!(cfgs[0].webchat, "https://w/");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue