experiment routinelike tokio spawn
All checks were successful
ci/woodpecker/push/cargo-checks Pipeline was successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
ModulatingForce 2024-03-20 01:06:59 -04:00
parent 46ecc15b67
commit 9b7650053e

View file

@ -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
}