Add ability to tell someone to read the f-ing chat

This commit is contained in:
2026-02-13 14:47:44 -05:00
parent 76c4c0b86d
commit 26d71ee449

View File

@@ -1,17 +1,27 @@
use irc::proto::Message;
use std::collections::VecDeque;
pub const PATTERN: &str = "^\\$rtf([cm])$";
pub const PATTERN: &str = "^\\$rtf([cm])( (?P<nick>[^\\s]+))?$";
pub const NAME: &str = "rtfm";
pub const USAGE: &str = "Usage: $rtf[cm]\r\nThis tells you read the f-ing manual or chat, whichever is chosen";
pub const USAGE: &str = "Usage: $rtf[cm] <nick>\r\nThis tells you read the f-ing manual or chat, whichever is chosen";
pub fn rtfm(captures: regex::Captures, _: &Message, _: &VecDeque<Message>) -> String {
let c_or_m = captures.get(1).unwrap().as_str();
if c_or_m == "c" {
"Read the f-ing chat".to_string()
if let Some(nick) = captures.get(2) {
if c_or_m == "c" {
format!("{}: Read the f-ing chat", nick.as_str())
}
else {
format!("{}: Read the f-ing manual", nick.as_str())
}
}
else {
"Read the f-ing manual".to_string()
if c_or_m == "c" {
"Read the f-ing chat".to_string()
}
else {
"Read the f-ing manual".to_string()
}
}
}