From 58fb0c91575a92550f0f9b0691bf26f7e0e603aa Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:48:54 -0500 Subject: [PATCH] added funny random listener/responder --- src/modules/experiments.rs | 71 +++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/modules/experiments.rs b/src/modules/experiments.rs index 0078ea8..7f028fa 100644 --- a/src/modules/experiments.rs +++ b/src/modules/experiments.rs @@ -22,29 +22,33 @@ use twitch_irc::message::PrivmsgMessage; use crate::core::identity; + +use rand::Rng; + + pub fn init(mgr:&mut ModulesManager) { + // BotCommand { + // module : BotModule(String::from("experiments 004")), + // command : String::from("test1"), // command call name + // alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names + // exec_body : actions_util::asyncbox(testy) , + // help : String::from("DUPCMD4 tester"), + // required_roles : vec![ + // //identity::UserRole::Mod(ChType::Channel(String::new())), + // identity::UserRole::SupMod(ChType::Channel(String::new())) + // ], + // }.add_to_modmgr(mgr); + + BotCommand { - module : BotModule(String::from("experiments 004")), + module : BotModule(String::from("experiments001")), command : String::from("test1"), // command call name alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names exec_body : actions_util::asyncbox(testy) , - help : String::from("DUPCMD4 tester"), - required_roles : vec![ - //identity::UserRole::Mod(ChType::Channel(String::new())), - identity::UserRole::SupMod(ChType::Channel(String::new())) - ], - }.add_to_modmgr(mgr); - - - BotCommand { - module : BotModule(String::from("experiments 004")), - command : String::from("test2"), // command call name - alias : vec![String::from("tester2"),String::from("testy2")], // String of alternative names - exec_body : actions_util::asyncbox(testy) , - help : String::from("DUPCMD4 tester"), + help : String::from("Test Command tester"), required_roles : vec![ identity::UserRole::BotAdmin ], @@ -52,14 +56,14 @@ pub fn init(mgr:&mut ModulesManager) - // let list1 = Listener { - // module : BotModule(String::from("experiments 004")), - // name : String::from("GoodGirl Listener"), - // exec_body : actions_util::asyncbox(good_girl) , - // help : String::from("") - // }; + let list1 = Listener { + module : BotModule(String::from("experiments001")), + name : String::from("GoodGirl Listener"), + exec_body : actions_util::asyncbox(good_girl) , + help : String::from("") + }; - // list1.add_to_modmgr(mgr); + list1.add_to_modmgr(mgr); } @@ -70,11 +74,30 @@ async fn good_girl(mut chat:botinstance::Chat,msg:PrivmsgMessage) println!("In GoodGirl()"); //println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); - if msg.sender.name == "ModulatingForce" && msg.message_text.contains("GoodGirl") { - chat.say_in_reply_to(&msg,String::from("GoodGirl")).await; + // [ ] Uses gen_ratio() to output bool based on a ratio probability . + // - For example gen_ratio(2,3) is 2 out of 3 or 0.67% (numerator,denomitator) + // - More Info : https://rust-random.github.io/rand/rand/trait.Rng.html#method.gen_ratio + + //let mut rng = thread_rng(); + + // let roll = rand::thread_rng().gen_range(1..=5); + + + + if msg.sender.name == "ModulatingForce" // && msg.message_text.contains("GoodGirl") + { + // chat.say_in_reply_to(&msg,String::from("GoodGirl")).await; + //if rng.gen_ratio(1,5) { + let rollwin = rand::thread_rng().gen_ratio(1,10); + if rollwin { + chat.say_in_reply_to(&msg,String::from("GoodGirl xdd ")).await; + } + } + + } async fn testy(mut _chat:botinstance::Chat,_msg:PrivmsgMessage)