Added noemo and grass
This commit is contained in:
@@ -6,13 +6,13 @@ use regex::Regex;
|
|||||||
//is this the best way to do this? probably not
|
//is this the best way to do this? probably not
|
||||||
mod modules;
|
mod modules;
|
||||||
|
|
||||||
use modules::{bully, lenny, join_rude};
|
use modules::{bully, lenny, join_rude, grass, noemo, ttb};
|
||||||
|
|
||||||
type ModuleFunc = fn(regex::Captures, &Message, &VecDeque<Message>)->Option<(String, String)>;
|
type ModuleFunc = fn(regex::Captures, &Message, &VecDeque<Message>)->Option<(String, String)>;
|
||||||
const NUM_MODS:usize = 2;
|
const NUM_MODS:usize = 5;
|
||||||
|
|
||||||
|
|
||||||
const MODULES: [(&str, ModuleFunc);NUM_MODS] = [(lenny::PATTERN, lenny::mod_message), (bully::PATTERN, bully::mod_message)];
|
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)];
|
||||||
|
|
||||||
pub fn build_modules() -> Result<Vec<(Regex, ModuleFunc)>, regex::Error> {
|
pub fn build_modules() -> Result<Vec<(Regex, ModuleFunc)>, regex::Error> {
|
||||||
let mut regex_array: Vec<(Regex, ModuleFunc)> = Vec::with_capacity(NUM_MODS);
|
let mut regex_array: Vec<(Regex, ModuleFunc)> = Vec::with_capacity(NUM_MODS);
|
||||||
|
|||||||
15
src/modules/grass.rs
Normal file
15
src/modules/grass.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
use irc::proto::Message;
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
|
pub const PATTERN: &str = "\\$grass (?P<nick>[^\\s]+)";
|
||||||
|
|
||||||
|
pub fn touch_grass(captures: regex::Captures, message: &Message, _: &VecDeque<Message>) -> Option<(String, String)> {
|
||||||
|
|
||||||
|
let grass_toucher = captures.get(1).unwrap().as_str();
|
||||||
|
|
||||||
|
let complete_message = format!("{} thinks you should go outside and touch some grass, {}",
|
||||||
|
message.source_nickname().unwrap_or("unknown_nick").to_string(),
|
||||||
|
grass_toucher);
|
||||||
|
|
||||||
|
Some((message.response_target().unwrap_or("#lug").to_string(), complete_message.to_string()))
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
pub mod bully;
|
pub mod bully;
|
||||||
pub mod lenny;
|
pub mod lenny;
|
||||||
pub mod join_rude;
|
pub mod join_rude;
|
||||||
|
pub mod grass;
|
||||||
|
pub mod ttb;
|
||||||
|
pub mod noemo;
|
||||||
|
|
||||||
|
|||||||
13
src/modules/noemo.rs
Normal file
13
src/modules/noemo.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
use irc::proto::Message;
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
|
pub const PATTERN: &str = "\\$noemo (?P<nick>[^\\s]+)";
|
||||||
|
|
||||||
|
pub fn no_emo(captures: regex::Captures, message: &Message, _: &VecDeque<Message>) -> Option<(String, String)> {
|
||||||
|
let emo_person = captures.get(1).unwrap().as_str();
|
||||||
|
|
||||||
|
let 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(),
|
||||||
|
emo_person);
|
||||||
|
Some((message.response_target().unwrap_or("#lug").to_string(), complete_message))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user