From 9cb8e514c6e983b244cb075a585ed97fc28a8275 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:24:40 -0400 Subject: [PATCH] testcmd to check botact header --- src/custom/experimental/experiment002.rs | 61 +++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/custom/experimental/experiment002.rs b/src/custom/experimental/experiment002.rs index a4ecb25..83ee118 100644 --- a/src/custom/experimental/experiment002.rs +++ b/src/custom/experimental/experiment002.rs @@ -26,7 +26,7 @@ use crate::core::botlog; use casual_logger::Log; use crate::core::bot_actions::actions_util; -use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager}; +use crate::core::botmodules::{BotAction, BotActionTrait, BotCommand, BotModule, ModulesManager}; use crate::core::identity::UserRole::*; @@ -55,7 +55,66 @@ pub async fn init(mgr: Arc) { // If enabling by defauling at instance level , uncomment the following // mgr.set_instance_enabled(BotModule(String::from("experiments002"))).await; + // 1. Define the BotAction + let botc1 = BotCommand { + module: BotModule(String::from("experiments002")), + command: String::from("testhelp"), // command call name + alias: vec![ + ], // String of alternative names + exec_body: actions_util::asyncbox(testhelp), + help: String::from("Help body - Success"), + required_roles: vec![ + BotAdmin, + // Mod(OF_CMD_CHANNEL), + // VIP(OF_CMD_CHANNEL), + ], + }; + + // 2. Add the BotAction to ModulesManager + botc1.add_to_modmgr(Arc::clone(&mgr)).await; + + + +} + + +async fn testhelp(params : ExecBodyParams) { + + if params.msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() + || params.msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase() + { + botlog::debug( + "Few Chosen triggered Testhelp!", + Some("experiments02 > testhelp()".to_string()), + Some(¶ms.msg), + ); + + let bot = Arc::clone(¶ms.bot); + + let botlock = bot.read().await; + + let curract = params.current_act.read().await; + + let helptext = match &*curract { + BotAction::C(a) => a.read().await.help.clone(), + BotAction::L(a) => a.read().await.help.clone(), + _ => "No Text Found".to_string() + }; + + botlock + .botmgrs + .chat + .say( + params.clone().msg.channel_login, + helptext.to_string(), + params.clone(), + ).await; + + + } + + Log::flush(); }