WIP: Child fn should be able to access BotAction Header #46
1 changed files with 60 additions and 1 deletions
|
@ -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<ModulesManager>) {
|
|||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue