diff --git a/src/modules/rtfm.rs b/src/modules/rtfm.rs index 08a38ef..7dc0553 100644 --- a/src/modules/rtfm.rs +++ b/src/modules/rtfm.rs @@ -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[^\\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] \r\nThis tells you read the f-ing manual or chat, whichever is chosen"; pub fn rtfm(captures: regex::Captures, _: &Message, _: &VecDeque) -> 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() + } } }