added funny random listener/responder
This commit is contained in:
parent
9fdb974813
commit
58fb0c9157
1 changed files with 47 additions and 24 deletions
|
@ -22,29 +22,33 @@ use twitch_irc::message::PrivmsgMessage;
|
||||||
|
|
||||||
use crate::core::identity;
|
use crate::core::identity;
|
||||||
|
|
||||||
|
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
|
||||||
pub fn init(mgr:&mut ModulesManager)
|
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 {
|
BotCommand {
|
||||||
module : BotModule(String::from("experiments 004")),
|
module : BotModule(String::from("experiments001")),
|
||||||
command : String::from("test1"), // command call name
|
command : String::from("test1"), // command call name
|
||||||
alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names
|
alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names
|
||||||
exec_body : actions_util::asyncbox(testy) ,
|
exec_body : actions_util::asyncbox(testy) ,
|
||||||
help : String::from("DUPCMD4 tester"),
|
help : String::from("Test Command 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"),
|
|
||||||
required_roles : vec![
|
required_roles : vec![
|
||||||
identity::UserRole::BotAdmin
|
identity::UserRole::BotAdmin
|
||||||
],
|
],
|
||||||
|
@ -52,14 +56,14 @@ pub fn init(mgr:&mut ModulesManager)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// let list1 = Listener {
|
let list1 = Listener {
|
||||||
// module : BotModule(String::from("experiments 004")),
|
module : BotModule(String::from("experiments001")),
|
||||||
// name : String::from("GoodGirl Listener"),
|
name : String::from("GoodGirl Listener"),
|
||||||
// exec_body : actions_util::asyncbox(good_girl) ,
|
exec_body : actions_util::asyncbox(good_girl) ,
|
||||||
// help : String::from("")
|
help : String::from("")
|
||||||
// };
|
};
|
||||||
|
|
||||||
// list1.add_to_modmgr(mgr);
|
list1.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,10 +74,29 @@ async fn good_girl(mut chat:botinstance::Chat,msg:PrivmsgMessage)
|
||||||
println!("In GoodGirl()");
|
println!("In GoodGirl()");
|
||||||
//println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
//println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||||
|
|
||||||
if msg.sender.name == "ModulatingForce" && msg.message_text.contains("GoodGirl") {
|
// [ ] Uses gen_ratio() to output bool based on a ratio probability .
|
||||||
chat.say_in_reply_to(&msg,String::from("GoodGirl")).await;
|
// - 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue