diff --git a/src/lib.rs b/src/lib.rs index 6161959..ab8104a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,14 +6,14 @@ use regex::Regex; //is this the best way to do this? probably not mod modules; -use modules::{bully, lenny, join_rude, grass, noemo, ttb, help, repo}; +use modules::{bully, lenny, join_rude, grass, noemo, ttb, help, repo,rtfm}; type ModuleFunc = fn(regex::Captures, &Message, &VecDeque)->String; -const NUM_MODS:usize = 7; +const NUM_MODS:usize = 8; -const MODULES: [(&str, ModuleFunc);NUM_MODS] = [(lenny::PATTERN, lenny::mod_message), (bully::PATTERN, bully::mod_message), (grass::PATTERN, grass::touch_grass), (noemo::PATTERN, noemo::no_emo), (ttb::PATTERN, ttb::time_to_baby), (help::PATTERN, help::help), (repo::PATTERN, repo::link)]; -const MODULE_USAGE: [(&str, &str); NUM_MODS] = [(lenny::NAME, lenny::USAGE), (bully::NAME, bully::USAGE), (grass::NAME, grass::USAGE), (noemo::NAME, noemo::USAGE), (ttb::NAME, ttb::USAGE), (help::NAME, help::USAGE), (repo::NAME, repo::USAGE)]; +const MODULES: [(&str, ModuleFunc);NUM_MODS] = [(lenny::PATTERN, lenny::mod_message), (bully::PATTERN, bully::mod_message), (grass::PATTERN, grass::touch_grass), (noemo::PATTERN, noemo::no_emo), (ttb::PATTERN, ttb::time_to_baby), (help::PATTERN, help::help), (repo::PATTERN, repo::link), (rtfm::PATTERN, rtfm::rtfm)]; +const MODULE_USAGE: [(&str, &str); NUM_MODS] = [(lenny::NAME, lenny::USAGE), (bully::NAME, bully::USAGE), (grass::NAME, grass::USAGE), (noemo::NAME, noemo::USAGE), (ttb::NAME, ttb::USAGE), (help::NAME, help::USAGE), (repo::NAME, repo::USAGE),(rtfm::NAME, rtfm::USAGE)]; pub fn build_modules() -> Result, regex::Error> { let mut regex_array: Vec<(Regex, ModuleFunc)> = Vec::with_capacity(NUM_MODS); diff --git a/src/modules/mod.rs b/src/modules/mod.rs index cd12b7f..83abf98 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -6,3 +6,5 @@ pub mod ttb; pub mod noemo; pub mod help; pub mod repo; +pub mod rtfm; + diff --git a/src/modules/rtfm.rs b/src/modules/rtfm.rs new file mode 100644 index 0000000..08a38ef --- /dev/null +++ b/src/modules/rtfm.rs @@ -0,0 +1,17 @@ +use irc::proto::Message; +use std::collections::VecDeque; + +pub const PATTERN: &str = "^\\$rtf([cm])$"; +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 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() + } + else { + "Read the f-ing manual".to_string() + } +}