From f8de595290c5bfabb1e591373964e0edc85755d5 Mon Sep 17 00:00:00 2001 From: haruyuumei Date: Thu, 28 Mar 2024 18:50:28 -0300 Subject: [PATCH] custom module update --- src/custom.rs | 4 +++- src/custom/experimental/experiment001.rs | 1 + src/{modules => custom}/thisguy.rs | 28 +++++++++++++++--------- src/lib.rs | 3 +-- src/modules.rs | 10 --------- src/modules/test.rs | 17 -------------- 6 files changed, 23 insertions(+), 40 deletions(-) rename src/{modules => custom}/thisguy.rs (73%) delete mode 100644 src/modules.rs delete mode 100644 src/modules/test.rs diff --git a/src/custom.rs b/src/custom.rs index 6107797..56c6257 100644 --- a/src/custom.rs +++ b/src/custom.rs @@ -13,6 +13,7 @@ pub use crate::core::botmodules::ModulesManager; // mod experiments; mod experimental; +mod thisguy; // [ ] init() function that accepts bot instance - this is passed to init() on submodules @@ -21,5 +22,6 @@ pub async fn init(mgr: Arc) { // this is achieved by calling submodules that also have fn init() defined // experiments::init(mgr).await - experimental::init(mgr).await; + experimental::init(mgr.clone()).await; + thisguy::init(&mgr).await; } diff --git a/src/custom/experimental/experiment001.rs b/src/custom/experimental/experiment001.rs index 28d499b..92af44d 100644 --- a/src/custom/experimental/experiment001.rs +++ b/src/custom/experimental/experiment001.rs @@ -105,6 +105,7 @@ async fn good_girl(params : ExecBodyParams) { if params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() || params.msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase() + || params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase() { botlog::debug( "Good Girl Detected > Pausechamp", diff --git a/src/modules/thisguy.rs b/src/custom/thisguy.rs similarity index 73% rename from src/modules/thisguy.rs rename to src/custom/thisguy.rs index 339d4c4..b5e895f 100644 --- a/src/modules/thisguy.rs +++ b/src/custom/thisguy.rs @@ -3,16 +3,26 @@ use crate::core::identity::UserRole::*; use crate::core::bot_actions::*; use crate::core::botlog; use std::sync::Arc; +use rand::Rng; use tokio::time::{sleep, Duration}; - +//use rand::Rng; async fn tsg(params: ExecBodyParams){ - - if params.msg.sender.name.to_lowercase() == "haruyuumei".to_lowercase() - //|| params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() + || params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() { + let phrases: [String;5] = [ + "Aware Weebs...".to_string(), + "AYAYA I love anime Girls!!".to_string(), + "I love 2d Girls ILOST".to_string(), + "UOOHHHHH!!! Anime Girlssss".to_string(), + "Anime girls u say? peepoShy".to_string(), + ]; + + let r = rand::thread_rng().gen_range(0..=4); + let a = phrases[r].clone(); + botlog::debug( "Oh god I love anime Girls!!", Some("modules > thisguy()".to_string()), @@ -26,8 +36,8 @@ async fn tsg(params: ExecBodyParams){ .botmgrs .chat .say_in_reply_to( - ¶ms.msg, - String::from("Oh god I love anime Girls!!"), + ¶ms.msg, + a, params.clone() ).await; sleep(Duration::from_secs_f64(0.5)).await; @@ -39,16 +49,14 @@ pub async fn init(mgr:&Arc){ BotCommand{ module:BotModule(String::from("thisguy")), - command: String::from("this"), - alias: vec![String::from("tsg")], + command: String::from("anime"), + alias: vec![String::from("Anime")], 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")), diff --git a/src/lib.rs b/src/lib.rs index f01fd10..667ce02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,2 @@ pub mod core; -pub mod custom; -pub mod modules; \ No newline at end of file +pub mod custom; \ No newline at end of file diff --git a/src/modules.rs b/src/modules.rs deleted file mode 100644 index d0b1c6e..0000000 --- a/src/modules.rs +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index ba7d68d..0000000 --- a/src/modules/test.rs +++ /dev/null @@ -1,17 +0,0 @@ -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; -}