diff --git a/.gitignore b/.gitignore index 188c46a..ec4d862 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,8 @@ target/ # env .envrc -.env \ No newline at end of file +.env + + +# log +.log \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 1425d4b..56bc71f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,30 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "async-trait" version = "0.1.77" @@ -61,12 +85,29 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "bytes" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +[[package]] +name = "casual_logger" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77d02b2f025328b7f0a232815634c840e206350cf7c8e8fb36ab7095e264f59c" +dependencies = [ + "chrono", + "lazy_static", + "regex", +] + [[package]] name = "cc" version = "1.0.83" @@ -88,7 +129,12 @@ version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", "num-traits", + "wasm-bindgen", + "windows-targets 0.48.5", ] [[package]] @@ -152,6 +198,7 @@ name = "forcebot_rs" version = "0.1.0" dependencies = [ "async-trait", + "casual_logger", "dotenv", "futures", "rand", @@ -289,6 +336,38 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "js-sys" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -549,6 +628,35 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -818,6 +926,69 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 0043332..3b8edd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ tokio = { version = "1.33.0", features = ["full"] } twitch-irc = "5.0.1" rand = { version = "0.8.5", features = [] } futures = "0.3" -async-trait = "0.1.77" \ No newline at end of file +async-trait = "0.1.77" +casual_logger = "0.6.5" \ No newline at end of file diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs index b2c065c..b0ef047 100644 --- a/src/core/botinstance.rs +++ b/src/core/botinstance.rs @@ -33,7 +33,7 @@ use crate::core::ratelimiter; use crate::core::botmodules; use crate::core::botmodules::ModulesManager; -use crate::core::identity::{IdentityManager,Permissible}; +use crate::core::identity::{IdentityManager,Permissible,ChangeResult}; use std::rc::Rc; use std::cell::RefCell; @@ -49,6 +49,51 @@ use core::borrow::Borrow; use super::botmodules::bot_actions::actions_util::BotAR; +use casual_logger::{Level,Log}; + + +pub mod botlog { + + /* + Module intends to add some layers to logging with the module user only requiring to pass : + - String Log message + - Option - Code Module + - Option - this is used to parse out Chatter & Channel into the logs + */ + + use casual_logger::{Level,Log}; + use twitch_irc::message::PrivmsgMessage; + + // trace, debug, info, notice, warn, error, fatal + + fn trace(in_msg:&str,module:Option,prvmsg:Option,) -> () { + + } + + fn debug(prvmsg:Option,in_msg:&str) -> () { + + } + + fn info(prvmsg:Option,in_msg:&str) -> () { + + } + + fn notice(prvmsg:Option,in_msg:&str) -> () { + + } + + fn warn(prvmsg:Option,in_msg:&str) -> () { + + } + + fn error(prvmsg:Option,in_msg:&str) -> () { + + } + +} + + + #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub enum ChType { Channel(String), @@ -110,15 +155,18 @@ impl Chat { } self.client.say_in_reply_to(msg,outmsg).await.unwrap(); - println!("(#{}) > {}", msg.channel_login, "rate limit counter increase"); + // println!("(#{}) > {}", msg.channel_login, "rate limit counter increase"); + Log::trace(&format!("(#{}) > {}", msg.channel_login, "rate limit counter increase")); contextratelimiter.increment_counter(); - println!("{:?}",self.ratelimiters); + // println!("{:?}",self.ratelimiters); + Log::trace(&format!("{:?}",self.ratelimiters)); }, ratelimiter::LimiterResp::Skip => { (); // do nothing otherwise } } + Log::flush(); } async fn say(&self, _:String, _:String) -> () { @@ -278,29 +326,42 @@ impl BotInstance ServerMessage::Notice(msg) => { match &msg.channel_login { - Some(chnl) => println!("NOTICE : (#{}) {}", chnl, msg.message_text), - None => println!("NOTICE : {}", msg.message_text), + Some(chnl) => { + // println!("NOTICE : (#{}) {}", chnl, msg.message_text) + Log::notice(&format!("NOTICE : (#{}) {}", chnl, msg.message_text)); + + }, + None => { + // println!("NOTICE : {}", msg.message_text); + Log::notice(&format!("NOTICE : {}", msg.message_text)); + }, } } ServerMessage::Privmsg(msg) => { - println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); + // println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); + Log::trace(&format!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text)); - println!("Privmsg section"); + // println!("Privmsg section"); + Log::debug(&format!("Privmsg section")); - BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await; + BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await; }, ServerMessage::Whisper(msg) => { - println!("(w) {}: {}", msg.sender.name, msg.message_text); + // println!("(w) {}: {}", msg.sender.name, msg.message_text); + Log::trace(&format!("(w) {}: {}", msg.sender.name, msg.message_text)); }, ServerMessage::Join(msg) => { - println!("JOINED: {}", msg.channel_login); + // println!("JOINED: {}", msg.channel_login); + Log::notice(&format!("JOINED: {}", msg.channel_login)); }, ServerMessage::Part(msg) => { - println!("PARTED: {}", msg.channel_login); + // println!("PARTED: {}", msg.channel_login); + Log::notice(&format!("PARTED: {}", msg.channel_login)); }, _ => {} - } + }; + Log::flush(); } }); @@ -342,7 +403,8 @@ impl BotInstance pub async fn listener_main_prvmsg(bot:BotAR,msg:&PrivmsgMessage) -> () { - println!(">> Inner listenermain_prvmsg()"); + // println!(">> Inner listenermain_prvmsg()"); + Log::trace(">> Inner listenermain_prvmsg()"); // let a = a; // println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); @@ -353,20 +415,24 @@ impl BotInstance let hacts = Arc::clone(&botlock.botmodules.botactions); // let hacts = hacts.read().await; let a = hacts.read().await; - println!("hacts size : {}",(*a).len()); + // println!("hacts size : {}",(*a).len()); + Log::debug(&format!("hacts size : {}",(*a).len())); - println!(">> Inner listenermain_prvmsg() >> before for loop of bot actions"); + // println!(">> Inner listenermain_prvmsg() >> before for loop of bot actions"); + Log::trace(">> Inner listenermain_prvmsg() >> before for loop of bot actions"); for (_m,acts) in &*hacts.read().await { - println!(">> Inner listenermain_prvmsg() >> checking bot actions"); + // println!(">> Inner listenermain_prvmsg() >> checking bot actions"); + Log::trace(">> Inner listenermain_prvmsg() >> checking bot actions"); // let bot = bot; for a in acts { - println!(">> Inner listenermain_prvmsg() >> checking bot actions >> 2"); + // println!(">> Inner listenermain_prvmsg() >> checking bot actions >> 2"); + Log::trace(">> Inner listenermain_prvmsg() >> checking bot actions >> 2"); let _act = match a { @@ -385,7 +451,8 @@ impl BotInstance // println!("args : {v}"); // } - println!("Reviewing internal commands"); + // println!("Reviewing internal commands"); + Log::trace("Reviewing internal commands"); let inpt = msg.message_text.split("\n").next().expect("ERROR during BotCommand"); let inpt = msg.message_text.split(" ").next().expect("ERROR during BotCommand"); @@ -413,29 +480,60 @@ impl BotInstance } if confirmed_bot_command { - println!("Confirmed bot command"); + // println!("Confirmed bot command"); + Log::debug("Confirmed bot command"); - println!("Going for botlock"); + // println!("Going for botlock"); + Log::trace("Going for botlock"); let botlock = bot.read().await; - println!("Going for identity"); + // println!("Going for identity"); + Log::trace("Going for identity"); let id = botlock.get_identity(); let eval = { let mut id = id.write().await; - println!("Unlocking identity"); - id.can_user_run_PRVMSG(&msg, c.required_roles.clone()).await + // println!("Unlocking identity"); + Log::trace("Unlocking identity"); + let (a,b) = id.can_user_run_PRVMSG(&msg, c.required_roles.clone()).await; + // // [-] #todo : need ot add functionality around here to do an o7 when a mod has been promoted => Preferring to do this outside the mutex + // if let ChangeResult::Success(b) = b { + // // let b = b.to_lowercase(); + // // let b = b.contains(&"Auto Promoted Mod".to_lowercase()); + // if b.to_lowercase().contains(&"Auto Promoted Mod".to_lowercase()) { + // let chat = + // } + // } + (a,b) }; - println!("Checking if permissible"); + // println!("Checking if permissible"); + Log::trace("Checking if permissible"); + + let (eval , rolechange) = eval; + + if let ChangeResult::Success(b) = rolechange { + + if b.to_lowercase().contains(&"Auto Promoted Mod".to_lowercase()) { + // println!("Read() lock Bot"); + Log::trace("Read() lock Bot"); + let botlock = bot.read().await; + let outstr = "o7 a Mod. I kneel to serve! pepeKneel ".to_string(); + (*botlock).botmgrs.chat.say_in_reply_to(msg, outstr).await; + } + } + match eval { Permissible::Allow => { - println!("Executed as permissible"); + // println!("Executed as permissible"); + Log::debug("Executed as permissible"); let a = Arc::clone(&bot); c.execute(a, msg.clone()).await; - println!("exit out of execution"); + // println!("exit out of execution"); + Log::trace("exit out of execution"); } Permissible::Block => { - println!("User Not allowed to run command") + // println!("User Not allowed to run command"); + Log::info("User Not allowed to run command"); }, // _ => (), }; @@ -459,11 +557,14 @@ impl BotInstance // // [ ] There should be a BotCommand Listener to check for prefixes ran - println!("End of Separate Listener Main prvmsg"); + // println!("End of Separate Listener Main prvmsg"); + Log::trace("End of Separate Listener Main prvmsg"); // self // bot + Log::flush(); + } diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index 20698cf..7075484 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -25,6 +25,7 @@ use std::rc::Rc; use async_trait::async_trait; +use casual_logger::{Level,Log}; /* @@ -199,13 +200,16 @@ impl BotActionTrait for Listener { async fn add_to_bot(self, bot:BotInstance) { - println!("Adding action to bot"); + // println!("Adding action to bot"); + Log::trace("Adding action to bot"); self.add_to_modmgr(bot.botmodules).await; } async fn add_to_modmgr(self, modmgr:Arc) { // let modmgr = *modmgr.lock().await; - println!("Adding action to module manager"); + // println!("Adding action to module manager"); + Log::trace("Adding action to module manager"); + modmgr.add_botaction(self.module.clone(), BotAction::L(self)).await; } diff --git a/src/core/identity.rs b/src/core/identity.rs index d60a6d5..c02e269 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -385,7 +385,7 @@ pub enum ChatBadge { } -enum ChangeResult { +pub enum ChangeResult { Success(String), Failed(String), NoChange(String), @@ -411,7 +411,7 @@ impl IdentityManager { // pub fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Result> // pub fn can_user_run_PRVMSG(&self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Permissible // pub async fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Permissible - pub async fn can_user_run_PRVMSG(&mut self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Permissible + pub async fn can_user_run_PRVMSG(&mut self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> (Permissible,ChangeResult) { // println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); @@ -454,6 +454,15 @@ impl IdentityManager { // cmdreqroles // ) ; // return a; + // return self.can_user_run(msg.sender.name.to_owned(), + // ChType::Channel(msg.channel_login.to_owned()), + // sender_badge, + // cmdreqroles + // ).await + + + // * NOTE : We're preferring to pass the ChangeResult up , where we have access to Chat via BotInstance + // that have more strained chatting rules return self.can_user_run(msg.sender.name.to_owned(), ChType::Channel(msg.channel_login.to_owned()), sender_badge, @@ -465,7 +474,7 @@ impl IdentityManager { // [ ] Call can_user_run() // (self,Permissible::Block) - Permissible::Block + (Permissible::Block,ChangeResult::NoChange("".to_string())) } @@ -475,7 +484,8 @@ impl IdentityManager { chat_badge:ChatBadge, cmdreqroles:Vec // ) -> Result> { - ) -> Permissible { + ) -> (Permissible,ChangeResult) { + println!{"Checking within can_user_run()"}; /* canUserRun - @@ -519,10 +529,12 @@ impl IdentityManager { if cmdreqroles.len() == 0 { // return Ok(Permissible::Allow) - return Permissible::Allow + return (Permissible::Allow , ChangeResult::NoChange("Command has no required cmdreqroles".to_string())) } + let mut modrolechange = ChangeResult::NoChange("".to_string()); + match chat_badge { @@ -535,7 +547,7 @@ impl IdentityManager { cmdreqroles.contains(&UserRole::Mod(ChType::Channel(String::new()))) || cmdreqroles.contains(&UserRole::SupMod(ChType::Channel(String::new()))) { // return Ok(Permissible::Allow) - return Permissible::Allow + return (Permissible::Allow , ChangeResult::NoChange("Broadcaster Role".to_string())) } }, @@ -563,30 +575,29 @@ impl IdentityManager { usrroles.read().await.contains(&UserRole::SupMod(channelname.clone())) => { // <-- working got to this point // println!("contains mod : {}", usrroles.read().await.contains(&UserRole::Mod(channelname.clone()))); // println!("contains supmod : {}", usrroles.read().await.contains(&UserRole::SupMod(channelname.clone()))); - // if usrroles.read().await.contains(&UserRole::Mod(channelname.clone())) || - // usrroles.read().await.contains(&UserRole::SupMod(channelname.clone())) { - // Do nothing - this is expected + + // Do nothing when theh have a mod badge and have either a supmod or mod badge for the channel println!("Already a mod in roles"); - // let a = &*self; - // let mut lock = a.special_roles_users.write().await; - // println!("lock created > adding with a mod role o7"); - // roleslock.get_mut(&usr.to_lowercase()) - // // .expect("ERROR") - // .unwrap() - // .write().await - // // .get_mut() - // .push(UserRole::Mod(channelname.clone())); - // println!("debug special roles : {:?}",self.special_roles_users); } _ => { + // In the event they have a mod badge , are running a bot command, but don't have a channel mod role yet... println!("lock created > adding with a mod role o7"); - roleslock.get_mut(&usr.to_lowercase()) - // .expect("ERROR") - .unwrap() - .write().await - // .get_mut() - .push(UserRole::Mod(channelname.clone())); + let mut roleslock = roleslock; + let mut a = roleslock.get_mut(&usr.to_lowercase()).unwrap(); + let mut alock = a.write().await; + + alock.push(UserRole::Mod(channelname.clone())); + + modrolechange = ChangeResult::Success("Auto Promoted Mod".to_string()); + + // alock.get_mut(&usr.to_lowercase()) + // .get_or_insert_with(|| UserRole::Mod(channelname.clone())) + // // .expect("ERROR") + // .unwrap() + // .write().await + // // .get_mut() + // .push(UserRole::Mod(channelname.clone())); } // <-- I'm assuming problem got to here } @@ -612,7 +623,7 @@ impl IdentityManager { if a.read().await.contains(&UserRole::Mod(channelname.clone())) || a.read().await.contains(&UserRole::SupMod(channelname.clone())){ // return Ok(Permissible::Allow); println!("Special roles found for user : A mod idenfified "); - return Permissible::Allow + return (Permissible::Allow , modrolechange) } } } @@ -625,7 +636,7 @@ impl IdentityManager { if let Some(a) = (&*self).special_roles_users.read().await.get(&usr.to_lowercase()) { if a.read().await.contains(&UserRole::SupMod(channelname.clone())) { // return Ok(Permissible::Allow); - return Permissible::Allow + return (Permissible::Allow,modrolechange) } } } @@ -641,12 +652,12 @@ impl IdentityManager { println!("special roles contains BotAdmin: {}",a.read().await.contains(&UserRole::BotAdmin)); if a.read().await.contains(&UserRole::BotAdmin) { // return Ok(Permissible::Allow); - return Permissible::Allow + return (Permissible::Allow,modrolechange) } } } - Permissible::Block + (Permissible::Block , ChangeResult::NoChange("Not any permissiable condition".to_string())) } // pub async fn promote(&mut self,trgchatter:String,channel:Option,trg_role:Option) -> ChangeResult { diff --git a/src/main.rs b/src/main.rs index 7847da3..07e4a13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,15 +7,23 @@ use std::process::Output; use crate::core::botinstance::ArcBox; use crate::core::botinstance::BotInstance; +use casual_logger::Extension; use tokio::sync::RwLock; use std::sync::Arc; pub type BotAR = Arc>; +use casual_logger::{Level,Log}; + #[tokio::main] pub async fn main() { + Log::set_file_ext(Extension::Log); + Log::set_level(Level::Trace); + // Log::set_level(Level::Notice); + let bot = BotInstance::init().await; + Log::debug("Checking bot actions"); let a = Arc::clone(&bot.botmodules.botactions); let a = a.read().await; // let a = *a; @@ -23,18 +31,32 @@ pub async fn main() { for (_,acts) in &*a { for act in acts { match act { - crate::core::botmodules::BotAction::C(b) => println!("bot actiions: {}",b.command), - crate::core::botmodules::BotAction::L(l) => println!("bot actiions: {}",l.name), - _ => println!("Not a valid match??"), + crate::core::botmodules::BotAction::C(b) => { + // println!("bot actiions: {}",b.command) + Log::info(&format!("bot actions: {}",b.command)); + }, + crate::core::botmodules::BotAction::L(l) => { + // println!("bot actiions: {}",l.name) + Log::info(&format!("bot actions: {}",l.name)); + }, + _ => { + // println!("Not a valid match??") + Log::info("Not a valid match??"); + }, } } }; - println!("Starting runner.."); + // println!("Starting runner.."); + Log::notice("Starting Bot Runner"); + + Log::flush(); bot.runner().await; - println!("ERROR : EXIT Game loop"); + // println!("ERROR : EXIT Game loop"); + // let msg = Log::fatal("ERROR : EXIT Game loop"); + panic!("{}",Log::fatal("ERROR : EXIT Game loop")); } \ No newline at end of file diff --git a/src/modules/experiments.rs b/src/modules/experiments.rs index 000f72a..f63192c 100644 --- a/src/modules/experiments.rs +++ b/src/modules/experiments.rs @@ -87,12 +87,12 @@ async fn good_girl(mut bot:BotAR,msg:PrivmsgMessage) // - More Info : https://rust-random.github.io/rand/rand/trait.Rng.html#method.gen_ratio - if msg.sender.name == "ModulatingForce" || msg.sender.name == "mzNToRi" // && msg.message_text.contains("GoodGirl") + if msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() || msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase() // && msg.message_text.contains("GoodGirl") { // chat.say_in_reply_to(&msg,String::from("GoodGirl")).await; //if rng.gen_ratio(1,5) { println!("In GoodGirl() > Pausechamp"); - let rollwin = rand::thread_rng().gen_ratio(1,10); + let rollwin = rand::thread_rng().gen_ratio(1,8); if rollwin { println!("In GoodGirl() > Win"); let a = Arc::clone(&bot);