diff --git a/src/custom/experimental/experiment001.rs b/src/custom/experimental/experiment001.rs index dd3cba4..28d499b 100644 --- a/src/custom/experimental/experiment001.rs +++ b/src/custom/experimental/experiment001.rs @@ -122,8 +122,6 @@ async fn good_girl(params : ExecBodyParams) { ); let bot = Arc::clone(¶ms.bot); - - let botlock = bot.read().await; // uses chat.say_in_reply_to() for the bot controls for messages @@ -135,8 +133,6 @@ async fn good_girl(params : ExecBodyParams) { String::from("GoodGirl xdd "), params.clone() ).await; - - } } } diff --git a/src/lib.rs b/src/lib.rs index c5ba775..f01fd10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,3 @@ pub mod core; pub mod custom; +pub mod modules; \ No newline at end of file diff --git a/src/modules.rs b/src/modules.rs new file mode 100644 index 0000000..d0b1c6e --- /dev/null +++ b/src/modules.rs @@ -0,0 +1,10 @@ +use std::sync::Arc; +pub use crate::core::botinstance::BotInstance; +pub use crate::core::botmodules::ModulesManager; + + +mod thisguy; + +pub async fn init(mgr:&Arc){ + thisguy::init(mgr).await; +} \ No newline at end of file diff --git a/src/modules/test.rs b/src/modules/test.rs new file mode 100644 index 0000000..ba7d68d --- /dev/null +++ b/src/modules/test.rs @@ -0,0 +1,17 @@ +use std::sync::Arc; + +// pub use crate::core::botinstance::BotInstance; +pub use crate::core::botmodules::ModulesManager; + +// [ ] Load submodules + +mod thisguy; + +// [ ] init() function that accepts bot instance - this is passed to init() on submodules + +pub async fn init(mgr: Arc) { + // Modules initializer loads modules into the bot + // this is achieved by calling submodules that also have fn init() defined + + thisguy::init(Arc::clone(&mgr)).await; +} diff --git a/src/modules/thisguy.rs b/src/modules/thisguy.rs new file mode 100644 index 0000000..339d4c4 --- /dev/null +++ b/src/modules/thisguy.rs @@ -0,0 +1,68 @@ +use crate::core::botmodules::{ BotActionTrait, BotCommand, BotModule, Listener, ModulesManager}; +use crate::core::identity::UserRole::*; +use crate::core::bot_actions::*; +use crate::core::botlog; +use std::sync::Arc; +use tokio::time::{sleep, Duration}; + + +async fn tsg(params: ExecBodyParams){ + + + + if params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase() + //|| params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() + { + botlog::debug( + "Oh god I love anime Girls!!", + 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 + botlock + .botmgrs + .chat + .say_in_reply_to( + ¶ms.msg, + String::from("Oh god I love anime Girls!!"), + params.clone() + ).await; + sleep(Duration::from_secs_f64(0.5)).await; + } + +} + +pub async fn init(mgr:&Arc){ + + BotCommand{ + module:BotModule(String::from("thisguy")), + command: String::from("this"), + alias: vec![String::from("tsg")], + exec_body: actions_util::asyncbox(tesst), + 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), + help: String::from(""), + }.add_to_modmgr(Arc::clone(&mgr)).await; +} + +async fn tesst(params : ExecBodyParams) { + println!("tesst triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call + botlog::debug( + "tesst triggered!", + Some("modules > tesst()".to_string()), + Some(¶ms.msg), + ); +}