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,13 +1,22 @@
use irc::proto::Message; use irc::proto::Message;
use std::collections::VecDeque; 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 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 { pub fn rtfm(captures: regex::Captures, _: &Message, _: &VecDeque<Message>) -> String {
let c_or_m = captures.get(1).unwrap().as_str(); let c_or_m = captures.get(1).unwrap().as_str();
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 {
if c_or_m == "c" { if c_or_m == "c" {
"Read the f-ing chat".to_string() "Read the f-ing chat".to_string()
} }
@@ -15,3 +24,4 @@ pub fn rtfm(captures: regex::Captures, _: &Message, _: &VecDeque<Message>) -> St
"Read the f-ing manual".to_string() "Read the f-ing manual".to_string()
} }
} }
}