Added rtfm module
This commit is contained in:
@@ -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<Message>)->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<Vec<(Regex, ModuleFunc)>, regex::Error> {
|
||||
let mut regex_array: Vec<(Regex, ModuleFunc)> = Vec::with_capacity(NUM_MODS);
|
||||
|
||||
@@ -6,3 +6,5 @@ pub mod ttb;
|
||||
pub mod noemo;
|
||||
pub mod help;
|
||||
pub mod repo;
|
||||
pub mod rtfm;
|
||||
|
||||
|
||||
17
src/modules/rtfm.rs
Normal file
17
src/modules/rtfm.rs
Normal file
@@ -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<Message>) -> 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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user