diff --git a/src/modules/noemo.rs b/src/modules/noemo.rs index 01f256b..ec125f2 100644 --- a/src/modules/noemo.rs +++ b/src/modules/noemo.rs @@ -1,13 +1,19 @@ use irc::proto::Message; use std::collections::VecDeque; -pub const PATTERN: &str = "^\\$noemo\\s*$"; +pub const PATTERN: &str = "^\\$noemo( (?P[^\\s]+))?$"; pub const NAME: &str = "noemo"; -pub const USAGE: &str = "Usage: $noemo \r\nThis tells the user identified by nick to not be emo"; +pub const USAGE: &str = "Usage: $noemo \r\nThis tells the user identified by nick to not be emo, nick is optional"; -pub fn no_emo(_: regex::Captures, message: &Message, _: &VecDeque) -> String { - let complete_message = format!("{} thinks you shouldn't be so emo. Take a deep breath and lighten up", +pub fn no_emo(captures : regex::Captures, message: &Message, _: &VecDeque) -> String { + let complete_message; + if let Some(person) = captures.get(2) { + complete_message = format!("{}: Don't be so emo. Take a deep breath and lighten up", person.as_str()); + } + else { + complete_message = format!("{} thinks you shouldn't be so emo. Take a deep breath and lighten up", message.source_nickname().unwrap_or("unknown_nick").to_string()); + } complete_message }