From bee5ba16e94efb686bb7b329b5e484f913ee4e19 Mon Sep 17 00:00:00 2001 From: Colin McKechney Date: Wed, 27 Mar 2024 22:02:10 -0700 Subject: [PATCH] Added repo module --- src/lib.rs | 8 ++++---- src/modules/mod.rs | 1 + src/modules/repo.rs | 12 ++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/modules/repo.rs diff --git a/src/lib.rs b/src/lib.rs index 8ac1ec0..6161959 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}; +use modules::{bully, lenny, join_rude, grass, noemo, ttb, help, repo}; type ModuleFunc = fn(regex::Captures, &Message, &VecDeque)->String; -const NUM_MODS:usize = 6; +const NUM_MODS:usize = 7; -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)]; -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)]; +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)]; 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 f5762cc..cd12b7f 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -5,3 +5,4 @@ pub mod grass; pub mod ttb; pub mod noemo; pub mod help; +pub mod repo; diff --git a/src/modules/repo.rs b/src/modules/repo.rs new file mode 100644 index 0000000..fd82edd --- /dev/null +++ b/src/modules/repo.rs @@ -0,0 +1,12 @@ +use irc::proto::Message; +use std::collections::VecDeque; + + +pub const PATTERN: &str = "^\\$repo\\s*$"; +pub const NAME: &str = "repo"; +pub const USAGE: &str = "Usage: $repo\r\nThis gives the link to the robbit repo"; +pub const REPO_LINK: &str = "https://github.com/ColinMcKechney/robbit.git"; + +pub fn link(_: regex::Captures, _: &Message, _: &VecDeque) -> String { + format!("{}\r\nPRs are always welcome!", REPO_LINK) +}