Compare commits
No commits in common. "b43d6f8159cf9e107f44f8f648e2673dcc593dba" and "d972eb77266dedf9cdfae2189dd586699e4ca080" have entirely different histories.
b43d6f8159
...
d972eb7726
1 changed files with 70 additions and 34 deletions
|
@ -1,42 +1,63 @@
|
||||||
use crate::core::bot_actions::*;
|
use crate::core::bot_actions::*;
|
||||||
use crate::core::botinstance::Channel;
|
|
||||||
use crate::core::botlog;
|
use crate::core::botlog;
|
||||||
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
|
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
|
||||||
use crate::core::identity::UserRole::*;
|
use crate::core::identity::UserRole::*;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
const OF_CMD_CHANNEL:Channel = Channel(String::new());
|
|
||||||
|
//using the env file to get bot prefix
|
||||||
|
use std::env;
|
||||||
|
use dotenv::dotenv;
|
||||||
|
|
||||||
|
//bot function
|
||||||
|
|
||||||
async fn tsg(params: ExecBodyParams) {
|
async fn tsg(params: ExecBodyParams) {
|
||||||
|
|
||||||
let phrases: [String; 6] = [
|
//Defining a var prefix to the prefix on the env file
|
||||||
"Clueless ".to_string(),
|
dotenv().ok();
|
||||||
"ICANT This guy....".to_string(),
|
let prefix = env::var("prefix").unwrap();
|
||||||
"He is right tho".to_string(),
|
/*
|
||||||
"KEKW true!".to_string(),
|
defining a text with the prefix + the command name (idk how to get the command)
|
||||||
"OMEGALUL wth man...".to_string(),
|
so for now i'm typing the command
|
||||||
"PepeLaugh El no sabe".to_string(),
|
*/
|
||||||
];
|
let text = String::from(&prefix) + "This";
|
||||||
|
let text2 = String::from(&prefix) + "this";
|
||||||
|
|
||||||
let r = rand::thread_rng().gen_range(0..=4);
|
//comparing the text sent with the text (prefix + command name)
|
||||||
let a = phrases[r].clone();
|
if params.msg.message_text == text
|
||||||
|
|| params.msg.message_text == text2
|
||||||
|
{
|
||||||
|
let phrases: [String; 6] = [
|
||||||
|
"Clueless".to_string(),
|
||||||
|
"ICANT This guy....".to_string(),
|
||||||
|
"He is right tho".to_string(),
|
||||||
|
"KEKW true!".to_string(),
|
||||||
|
"OMEGALUL wth man...".to_string(),
|
||||||
|
"PepeLaugh El no sabe".to_string(),
|
||||||
|
];
|
||||||
|
|
||||||
botlog::debug(
|
let r = rand::thread_rng().gen_range(0..=4);
|
||||||
"This guy works!",
|
let a = phrases[r].clone();
|
||||||
Some("modules > thisguy()".to_string()),
|
|
||||||
Some(¶ms.msg),
|
|
||||||
);
|
|
||||||
let bot = Arc::clone(¶ms.bot);
|
|
||||||
let botlock = bot.read().await;
|
|
||||||
|
|
||||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
botlog::debug(
|
||||||
botlock
|
"This guy works!",
|
||||||
.botmgrs
|
Some("modules > thisguy()".to_string()),
|
||||||
.chat
|
Some(¶ms.msg),
|
||||||
.say_in_reply_to(¶ms.msg, a, params.clone())
|
);
|
||||||
.await;
|
let bot = Arc::clone(¶ms.bot);
|
||||||
sleep(Duration::from_secs_f64(0.5)).await;
|
let botlock = bot.read().await;
|
||||||
|
|
||||||
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
|
botlock
|
||||||
|
.botmgrs
|
||||||
|
.chat
|
||||||
|
.say_in_reply_to(¶ms.msg, a, params.clone())
|
||||||
|
.await;
|
||||||
|
sleep(Duration::from_secs_f64(0.5)).await;
|
||||||
|
}else {
|
||||||
|
//println!("didn't type the proper command");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init(mgr: &Arc<ModulesManager>) {
|
pub async fn init(mgr: &Arc<ModulesManager>) {
|
||||||
|
@ -44,14 +65,29 @@ pub async fn init(mgr: &Arc<ModulesManager>) {
|
||||||
module: BotModule(String::from("thisguy")),
|
module: BotModule(String::from("thisguy")),
|
||||||
command: String::from("thisguy"),
|
command: String::from("thisguy"),
|
||||||
alias: vec![String::from("Thisguy")],
|
alias: vec![String::from("Thisguy")],
|
||||||
exec_body: actions_util::asyncbox(tsg),
|
exec_body: actions_util::asyncbox(test),
|
||||||
help: String::from("test"),
|
help: String::from("test"),
|
||||||
required_roles: vec![
|
required_roles: vec![BotAdmin],
|
||||||
BotAdmin,
|
|
||||||
Mod(OF_CMD_CHANNEL),
|
|
||||||
Broadcaster
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
.add_to_modmgr(Arc::clone(&mgr))
|
.add_to_modmgr(Arc::clone(&mgr))
|
||||||
.await;
|
.await;
|
||||||
}
|
|
||||||
|
Listener {
|
||||||
|
module: BotModule(String::from("thisguy")),
|
||||||
|
name: String::from("This Guy Listener"),
|
||||||
|
exec_body: actions_util::asyncbox(tsg),
|
||||||
|
help: String::from(""),
|
||||||
|
}
|
||||||
|
.add_to_modmgr(Arc::clone(&mgr))
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async fn test(params: ExecBodyParams) {
|
||||||
|
println!("Test triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
|
||||||
|
botlog::debug(
|
||||||
|
"test triggered!",
|
||||||
|
Some("modules > tesst()".to_string()),
|
||||||
|
Some(¶ms.msg),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue