custom - babygirl cmd

This commit is contained in:
ModulatingForce 2024-03-19 18:02:13 -04:00
parent f54990a502
commit 46ecc15b67

View file

@ -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<ModulesManager>) {
const OF_CMD_CHANNEL:ChType = Channel(String::new());
@ -57,6 +59,36 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// 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;
}