diff --git a/src/custom/experiments.rs b/src/custom/experiments.rs index cda042d..d4e567e 100644 --- a/src/custom/experiments.rs +++ b/src/custom/experiments.rs @@ -25,6 +25,8 @@ use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, M use crate::core::identity::UserRole::*; +use tokio::time::{sleep, Duration}; + pub async fn init(mgr: Arc) { const OF_CMD_CHANNEL:ChType = Channel(String::new()); @@ -57,6 +59,36 @@ pub async fn init(mgr: Arc) { // 2. Add the BotAction to ModulesManager list1.add_to_modmgr(Arc::clone(&mgr)).await; + + + // // 1. Define the BotAction + // let list1 = Listener { + // module: BotModule(String::from("experiments001")), + // name: String::from("babygirl Listener"), + // exec_body: actions_util::asyncbox(babygirl), + // help: String::from(""), + // }; + + // // 2. Add the BotAction to ModulesManager + // list1.add_to_modmgr(Arc::clone(&mgr)).await; + + // 1. Define the BotAction + let botc1 = BotCommand { + module: BotModule(String::from("experiments001")), + command: String::from("babygirl"), // command call name + alias: vec![], // String of alternative names + exec_body: actions_util::asyncbox(babygirl), + help: String::from("Babygirl"), + required_roles: vec![ + BotAdmin, + // Mod(OF_CMD_CHANNEL), + Broadcaster, + ], + }; + + // 2. Add the BotAction to ModulesManager + botc1.add_to_modmgr(Arc::clone(&mgr)).await; + } async fn good_girl(bot: BotAR, msg: PrivmsgMessage) { @@ -105,3 +137,45 @@ async fn testy(mut _chat: BotAR, msg: PrivmsgMessage) { Some(&msg), ); } + + +async fn babygirl(bot: BotAR, msg: PrivmsgMessage) { + println!("babygirl triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call + botlog::debug( + "babygirl triggered!", + Some("experiments > babygirl()".to_string()), + Some(&msg), + ); + + + let bot = Arc::clone(&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(&msg, String::from("16:13 notohh: cafdk")) + .await; + + + sleep(Duration::from_secs_f64(0.5)).await; + + botlock + .botmgrs + .chat + .say_in_reply_to(&msg, String::from("16:13 notohh: have fun eating princess")) + .await; + + + sleep(Duration::from_secs_f64(2.0)).await; + + botlock + .botmgrs + .chat + .say_in_reply_to(&msg, String::from("16:13 notohh: baby girl")) + .await; + + +}