added funny random listener/responder

This commit is contained in:
ModulatingForce 2024-01-30 11:48:54 -05:00
parent 9fdb974813
commit 58fb0c9157

View file

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