Add bonk module

This commit is contained in:
2026-02-13 14:56:34 -05:00
parent 26d71ee449
commit 72caa70606
3 changed files with 23 additions and 4 deletions

View File

@@ -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,rtfm, kick, history, time_to_date};
use modules::{bully, lenny, join_rude, grass, noemo, ttb, help, repo,rtfm, kick, history, time_to_date, bonk};
type ModuleFunc = fn(regex::Captures, &Message, &VecDeque<Message>)->String;
const NUM_MODS:usize = 11;
const NUM_MODS:usize = 12;
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), (kick::PATTERN, kick::mod_message), (history::PATTERN, history::mod_message), (time_to_date::PATTERN, time_to_date::time_to_date)];
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), (kick::NAME, kick::USAGE), (history::NAME, history::USAGE), (time_to_date::NAME, time_to_date::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), (kick::PATTERN, kick::mod_message), (history::PATTERN, history::mod_message), (time_to_date::PATTERN, time_to_date::time_to_date), (bonk::PATTERN, bonk::bonk)];
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), (kick::NAME, kick::USAGE), (history::NAME, history::USAGE), (time_to_date::NAME, time_to_date::USAGE), (bonk::NAME, bonk::USAGE)];
pub fn build_modules() -> Result<Vec<(Regex, ModuleFunc)>, regex::Error> {
let mut regex_array: Vec<(Regex, ModuleFunc)> = Vec::with_capacity(NUM_MODS);

18
src/modules/bonk.rs Normal file
View File

@@ -0,0 +1,18 @@
use std::collections::VecDeque;
use irc::proto::Message;
pub const USAGE: &str = "Usage: $bonk <nick>\r\nPut the person identified as nick in horny jail";
pub const NAME: &str = "bonk";
pub const PATTERN: &str = "^\\$bonk( (?P<nick>[^\\s]+))?$";
pub fn bonk(captures: regex::Captures, _message: &Message, _message_buf: &VecDeque<Message>) -> String {
if let Some(nick) = captures.get(2) {
format!("bonk! {} go to horny jail!", nick.as_str())
}
else {
format!("bonk! go to horny jail!")
}
}

View File

@@ -10,3 +10,4 @@ pub mod rtfm;
pub mod kick;
pub mod history;
pub mod time_to_date;
pub mod bonk;