renamed module dir to modules
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
nickname = "robbit"
|
||||
username = "robbit"
|
||||
realname = "robbit"
|
||||
server = "chat.ndlug.org"
|
||||
port = 6697
|
||||
channels = ["#bots"]
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,9 @@ 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 struct Bully{}
|
||||
|
||||
impl Bully {
|
||||
pub fn mod_message(message: &Message, message_buf: &VecDeque<Message>) -> Option<(String,String)> {
|
||||
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() {
|
||||
@@ -44,9 +39,8 @@ impl Bully {
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn usage(message: &Message) -> (String, String) {
|
||||
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
34
src/modules/lenny.rs
Normal 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
4
src/modules/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
pub mod bully;
|
||||
pub mod lenny;
|
||||
pub mod join_rude;
|
||||
|
||||
Reference in New Issue
Block a user