Compare commits

..

2 commits

Author SHA1 Message Date
b43d6f8159 Rewriten the code
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
working with command instead listener
2024-04-03 10:26:14 -03:00
7e04699b67 making changes 2024-04-03 10:25:24 -03:00

View file

@ -1,33 +1,15 @@
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, Listener, ModulesManager}; use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, 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) {
//Defining a var prefix to the prefix on the env file
dotenv().ok();
let prefix = env::var("prefix").unwrap();
/*
defining a text with the prefix + the command name (idk how to get the command)
so for now i'm typing the command
*/
let text = String::from(&prefix) + "This";
let text2 = String::from(&prefix) + "this";
//comparing the text sent with the text (prefix + command name)
if params.msg.message_text == text
|| params.msg.message_text == text2
{
let phrases: [String; 6] = [ let phrases: [String; 6] = [
"Clueless ".to_string(), "Clueless ".to_string(),
"ICANT This guy....".to_string(), "ICANT This guy....".to_string(),
@ -55,9 +37,6 @@ async fn tsg(params: ExecBodyParams) {
.say_in_reply_to(&params.msg, a, params.clone()) .say_in_reply_to(&params.msg, a, params.clone())
.await; .await;
sleep(Duration::from_secs_f64(0.5)).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>) {
@ -65,29 +44,14 @@ 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(test),
help: String::from("test"),
required_roles: vec![BotAdmin],
}
.add_to_modmgr(Arc::clone(&mgr))
.await;
Listener {
module: BotModule(String::from("thisguy")),
name: String::from("This Guy Listener"),
exec_body: actions_util::asyncbox(tsg), exec_body: actions_util::asyncbox(tsg),
help: String::from(""), help: String::from("test"),
required_roles: vec![
BotAdmin,
Mod(OF_CMD_CHANNEL),
Broadcaster
],
} }
.add_to_modmgr(Arc::clone(&mgr)) .add_to_modmgr(Arc::clone(&mgr))
.await; .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(&params.msg),
);
}