renamed module dir to modules

This commit is contained in:
2024-03-26 18:00:32 -07:00
parent 54bf544760
commit 15982188f5
6 changed files with 52 additions and 64 deletions

View File

@@ -1,6 +0,0 @@
nickname = "robbit"
username = "robbit"
realname = "robbit"
server = "chat.ndlug.org"
port = 6697
channels = ["#bots"]

View File

@@ -1,38 +0,0 @@
use std::collections::VecDeque;
use irc::proto::{Message, Command::*};
use regex::Regex;
use rand::prelude::Rng;
const LENNYS:[&str;12] = ["( ͡° ͜ʖ ͡°)","( ͠° ͟ʖ ͡°)","ᕦ( ͡° ͜ʖ ͡°)ᕤ","( ͡° ͜ʖ ͡°)","( ͡~ ͜ʖ ͡°)","( ͡o ͜ʖ ͡o)","͡° ͜ʖ ͡ -","( ͡͡ ° ͜ ʖ ͡ °)","( ͡ ͡° ͡° ʖ ͡° ͡°)","(ง ͠° ͟ل͜ ͡°)ง","( ͡° ͜ʖ ͡ °)","( ͡°╭͜ʖ╮͡° )"];
const PATTERN: &str = "^![Ll]enny\\s*(?P<text>.*)$";
const USAGE: &str = "Usage: ![Ll]enny
Displays a Lenny face ( ͡° ͜ʖ ͡°)";
pub struct Lenny {}
#[allow(unused_variables)]
impl Lenny {
pub fn mod_message(message: &Message, message_buf: &VecDeque<Message>) -> Option<(String,String)> {
let regex: Regex = Regex::new(PATTERN).expect("Error creating regex");
//checks if it was a PRIVMSG
if let PRIVMSG(_,msg) = message.command.clone() {
//checks if it was lenny
if let Some(captures) = regex.captures(msg.as_str()) {
let lenny = LENNYS[rand::thread_rng().gen_range(0..12)].to_string();
let text = captures.get(1).unwrap().as_str();
return Some((message.response_target().unwrap_or("#lug").to_string(),format!("{} {}", lenny, text)));
}
}
None
}
pub fn usage(message: &Message) -> (String,String) {
//prints a usage, not sure when I'm gonna use this but let's see
(message.response_target().unwrap_or("#lug").to_string(),USAGE.to_string())
}
}

View File

@@ -23,30 +23,24 @@ const BULLY_PHRASES:[&str;12] = [
" thinks you were probably the pilot of Ever Given when it clogged the Suez Canal, "
];
const PATTERN: &str = "^!bully (?P<nick>[^\\s]+)";
const PATTERN: &str = "^\\$bully (?P<nick>[^\\s]+)";
pub fn mod_message(message: &Message, message_buf: &VecDeque<Message>) -> Option<(String,String)> {
let regex: Regex = Regex::new(PATTERN).expect("Error creating regex");
if let PRIVMSG(_,msg) = message.command.clone() {
if let Some(capture) = regex.captures(msg.as_str()) {
let bully_message: String = BULLY_PHRASES[rand::thread_rng().gen_range(0..BULLY_PHRASES.len())].to_string();
let to_be_bullied = capture.get(1).unwrap().as_str();
pub struct Bully{}
let complete_message = message.source_nickname().unwrap_or("unknown_nick").to_string() + bully_message.as_str() + to_be_bullied;
impl Bully {
pub fn mod_message(message: &Message, message_buf: &VecDeque<Message>) -> Option<(String,String)> {
let regex: Regex = Regex::new(PATTERN).expect("Error creating regex");
if let PRIVMSG(_,msg) = message.command.clone() {
if let Some(capture) = regex.captures(msg.as_str()) {
let bully_message: String = BULLY_PHRASES[rand::thread_rng().gen_range(0..BULLY_PHRASES.len())].to_string();
let to_be_bullied = capture.get(1).unwrap().as_str();
let complete_message = message.source_nickname().unwrap_or("unknown_nick").to_string() + bully_message.as_str() + to_be_bullied;
return Some((message.response_target().unwrap_or("#lug").to_string(), complete_message));
}
return Some((message.response_target().unwrap_or("#lug").to_string(), complete_message));
}
None
}
pub fn usage(message: &Message) -> (String, String) {
(message.response_target().unwrap_or("#lug").to_string(), USAGE.to_string())
}
None
}
pub fn usage(message: &Message) -> (String, String) {
(message.response_target().unwrap_or("#lug").to_string(), USAGE.to_string())
}

34
src/modules/lenny.rs Normal file
View File

@@ -0,0 +1,34 @@
use std::collections::VecDeque;
use irc::proto::{Message, Command::*};
use regex::Regex;
use rand::prelude::Rng;
const LENNYS:[&str;12] = ["( ͡° ͜ʖ ͡°)","( ͠° ͟ʖ ͡°)","ᕦ( ͡° ͜ʖ ͡°)ᕤ","( ͡° ͜ʖ ͡°)","( ͡~ ͜ʖ ͡°)","( ͡o ͜ʖ ͡o)","͡° ͜ʖ ͡ -","( ͡͡ ° ͜ ʖ ͡ °)","( ͡ ͡° ͡° ʖ ͡° ͡°)","(ง ͠° ͟ل͜ ͡°)ง","( ͡° ͜ʖ ͡ °)","( ͡°╭͜ʖ╮͡° )"];
const PATTERN: &str = "^\\$[Ll]enny\\s*(?P<text>.*)$";
const USAGE: &str = "Usage: ![Ll]enny
Displays a Lenny face ( ͡° ͜ʖ ͡°)";
pub fn mod_message(message: &Message, message_buf: &VecDeque<Message>) -> Option<(String,String)> {
let regex: Regex = Regex::new(PATTERN).expect("Error creating regex");
//checks if it was a PRIVMSG
if let PRIVMSG(_,msg) = message.command.clone() {
//checks if it was lenny
if let Some(captures) = regex.captures(msg.as_str()) {
let lenny = LENNYS[rand::thread_rng().gen_range(0..12)].to_string();
let text = captures.get(1).unwrap().as_str();
return Some((message.response_target().unwrap_or("#lug").to_string(),format!("{} {}", lenny, text)));
}
}
None
}
pub fn usage(message: &Message) -> (String,String) {
//prints a usage, not sure when I'm gonna use this but let's see
(message.response_target().unwrap_or("#lug").to_string(),USAGE.to_string())
}

4
src/modules/mod.rs Normal file
View File

@@ -0,0 +1,4 @@
pub mod bully;
pub mod lenny;
pub mod join_rude;