From 9b7650053e6af6c9701f5025cc7a2a92bb0c2b26 Mon Sep 17 00:00:00 2001
From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com>
Date: Wed, 20 Mar 2024 01:06:59 -0400
Subject: [PATCH] experiment routinelike tokio spawn

---
 src/custom/experiments.rs | 45 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/src/custom/experiments.rs b/src/custom/experiments.rs
index d4e567e..de2f424 100644
--- a/src/custom/experiments.rs
+++ b/src/custom/experiments.rs
@@ -89,6 +89,25 @@ pub async fn init(mgr: Arc<ModulesManager>) {
     // 2. Add the BotAction to ModulesManager
     botc1.add_to_modmgr(Arc::clone(&mgr)).await;
 
+
+    
+    // 1. Define the BotAction
+    let botc1 = BotCommand {
+        module: BotModule(String::from("experiments001")),
+        command: String::from("rtest"), // command call name
+        alias: vec![], // String of alternative names
+        exec_body: actions_util::asyncbox(routinelike),
+        help: String::from("routinelike"),
+        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) {
@@ -179,3 +198,29 @@ async fn babygirl(bot: BotAR, msg: PrivmsgMessage) {
 
 
 }
+
+
+
+
+async fn routinelike(_bot: BotAR, msg: PrivmsgMessage) {
+    println!("routinelike triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
+    botlog::debug(
+        "routinelike triggered!",
+        Some("experiments > routinelike()".to_string()),
+        Some(&msg),
+    );
+
+    // spawn an async block that runs independently from others
+
+    tokio::spawn( async {
+        for _ in 0..5 {
+            println!(">> Innterroutine triggered!");
+            sleep(Duration::from_secs_f64(5.0)).await;
+            }   
+        }
+    );
+
+    // lines are executed after in conjunction to the spawn 
+
+}
+