botlog module

This commit is contained in:
ModulatingForce 2024-03-02 10:06:26 -05:00
parent a2747b1ad5
commit 90b9b66e6d
9 changed files with 404 additions and 238 deletions

View file

@ -1,4 +1,5 @@
pub mod botinstance; pub mod botinstance;
pub mod botlog;
pub mod botmodules; pub mod botmodules;
pub mod identity; pub mod identity;
pub mod ratelimiter; pub mod ratelimiter;

View file

@ -1,15 +1,14 @@
use std::sync::Arc;
use std::env;
use std::collections::HashMap; use std::collections::HashMap;
use std::env;
use std::sync::Arc;
use tokio::sync::mpsc::UnboundedReceiver; use tokio::sync::mpsc::UnboundedReceiver;
use tokio::sync::{RwLock,Mutex}; use tokio::sync::{Mutex, RwLock};
use twitch_irc::login::StaticLoginCredentials; use twitch_irc::login::StaticLoginCredentials;
use twitch_irc::message::{PrivmsgMessage,ServerMessage}; use twitch_irc::message::{PrivmsgMessage, ServerMessage};
use twitch_irc::transport::tcp::{TCPTransport,TLS}; use twitch_irc::transport::tcp::{TCPTransport, TLS};
use twitch_irc::{ClientConfig,SecureTCPTransport,TwitchIRCClient}; use twitch_irc::{ClientConfig, SecureTCPTransport, TwitchIRCClient};
use dotenv::dotenv; use dotenv::dotenv;
@ -20,189 +19,188 @@ use rand::Rng;
use crate::core::ratelimiter; use crate::core::ratelimiter;
use crate::core::ratelimiter::RateLimiter; use crate::core::ratelimiter::RateLimiter;
use crate::core::botmodules::ModulesManager;
use crate::core::botmodules::bot_actions::actions_util::BotAR; use crate::core::botmodules::bot_actions::actions_util::BotAR;
use crate::core::botmodules::ModulesManager;
use crate::core::identity::{ChangeResult, IdentityManager, Permissible}; use crate::core::identity::{ChangeResult, IdentityManager, Permissible};
use crate::core::botlog;
pub mod botlog { // pub mod botlog {
/* // /*
Module intends to add some layers to logging with the module user only requiring to pass : // Module intends to add some layers to logging with the module user only requiring to pass :
- String Log message // - String Log message
- Option<String> - Code_Module // - Option<String> - Code_Module
- Option<PrivmsgMessage> - this is used to parse out Chatter & Channel into the logs // - Option<PrivmsgMessage> - this is used to parse out Chatter & Channel into the logs
*/ // */
// // use casual_logger::{Level, Log};
// use casual_logger::Log;
// use twitch_irc::message::PrivmsgMessage;
// use casual_logger::{Level, Log}; // // trace, debug, info, notice, warn, error, fatal
use casual_logger::Log;
use twitch_irc::message::PrivmsgMessage;
// trace, debug, info, notice, warn, error, fatal // /*
/* // in main : Log::debug("Checking bot actions", Some("main()".to_string()), None);
in main : Log::debug("Checking bot actions", Some("main()".to_string()), None); // in log :
// [blalba@timestmp]
// debug = "Checking bot actions",
in log : // */
[blalba@timestmp] // pub fn trace(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
debug = "Checking bot actions", // let (chnl, chatter) = match in_prvmsg {
// Some(prvmsg) => {
// //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
// (
// Some(prvmsg.channel_login.clone()),
// Some(prvmsg.sender.name.clone()),
// ) // <-- Clone fine atm while we're just working with Strings
// }
// None => (None, None),
// };
*/ // Log::trace_t(
// in_msg,
// casual_logger::Table::default() //
// .str("Channel", &format!("{:?}", chnl))
// .str("Chatter", &format!("{:?}", chatter))
// .str("Code_Module", &format!("{:?}", in_module)),
// );
// }
pub fn trace(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) { // pub fn debug(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg { // let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => { // Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text)); // //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
( // (
Some(prvmsg.channel_login.clone()), // Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()), // Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings // ) // <-- Clone fine atm while we're just working with Strings
} // }
None => (None, None), // None => (None, None),
}; // };
Log::trace_t( // Log::debug_t(
in_msg, // in_msg,
casual_logger::Table::default() // // casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl)) // .str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter)) // .str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)), // .str("Code_Module", &format!("{:?}", in_module)),
); // );
} // }
pub fn debug(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) { // pub fn info(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg { // let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => { // Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text)); // //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
( // (
Some(prvmsg.channel_login.clone()), // Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()), // Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings // ) // <-- Clone fine atm while we're just working with Strings
} // }
None => (None, None), // None => (None, None),
}; // };
Log::debug_t( // Log::info_t(
in_msg, // in_msg,
casual_logger::Table::default() // // casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl)) // .str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter)) // .str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)), // .str("Code_Module", &format!("{:?}", in_module)),
); // );
} // }
pub fn info(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) { // pub fn notice(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg { // let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => { // Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text)); // //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
( // (
Some(prvmsg.channel_login.clone()), // Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()), // Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings // ) // <-- Clone fine atm while we're just working with Strings
} // }
None => (None, None), // None => (None, None),
}; // };
Log::info_t( // Log::notice_t(
in_msg, // in_msg,
casual_logger::Table::default() // // casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl)) // .str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter)) // .str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)), // .str("Code_Module", &format!("{:?}", in_module)),
); // );
} // }
pub fn notice(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) { // pub fn warn(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg { // let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => { // Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text)); // //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
( // (
Some(prvmsg.channel_login.clone()), // Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()), // Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings // ) // <-- Clone fine atm while we're just working with Strings
} // }
None => (None, None), // None => (None, None),
}; // };
Log::notice_t( // Log::warn_t(
in_msg, // in_msg,
casual_logger::Table::default() // // casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl)) // .str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter)) // .str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)), // .str("Code_Module", &format!("{:?}", in_module)),
); // );
} // }
pub fn warn(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) { // pub fn error(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg { // let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => { // Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text)); // //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
( // (
Some(prvmsg.channel_login.clone()), // Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()), // Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings // ) // <-- Clone fine atm while we're just working with Strings
} // }
None => (None, None), // None => (None, None),
}; // };
Log::warn_t( // Log::error_t(
in_msg, // in_msg,
casual_logger::Table::default() // // casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl)) // .str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter)) // .str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)), // .str("Code_Module", &format!("{:?}", in_module)),
); // );
} // }
pub fn error(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) { // pub fn fatal<'a>(
let (chnl, chatter) = match in_prvmsg { // in_msg: &'a str,
Some(prvmsg) => { // in_module: Option<String>,
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text)); // in_prvmsg: Option<&PrivmsgMessage>,
( // ) -> &'a str {
Some(prvmsg.channel_login.clone()), // let (chnl, chatter) = match in_prvmsg {
Some(prvmsg.sender.name.clone()), // Some(prvmsg) => {
) // <-- Clone fine atm while we're just working with Strings // //Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
} // (
None => (None, None), // Some(prvmsg.channel_login.clone()),
}; // Some(prvmsg.sender.name.clone()),
// ) // <-- Clone fine atm while we're just working with Strings
// }
// None => (None, None),
// };
Log::error_t( // Log::fatal_t(
in_msg, // in_msg,
casual_logger::Table::default() // // casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl)) // .str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter)) // .str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)), // .str("Code_Module", &format!("{:?}", in_module)),
); // );
}
pub fn fatal<'a>( // in_msg
in_msg: &'a str, // }
in_module: Option<String>, // }
in_prvmsg: Option<&PrivmsgMessage>,
) -> &'a str {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::fatal_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
in_msg
}
}
#[derive(Debug, PartialEq, Eq, Hash, Clone)] #[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum ChType { pub enum ChType {

175
src/core/botlog.rs Normal file
View file

@ -0,0 +1,175 @@
/*
Module intends to add some layers to logging with the module user only requiring to pass :
- String Log message
- Option<String> - Code_Module
- Option<PrivmsgMessage> - this is used to parse out Chatter & Channel into the logs
*/
// use casual_logger::{Level, Log};
use casual_logger::Log;
use twitch_irc::message::PrivmsgMessage;
// trace, debug, info, notice, warn, error, fatal
/*
in main : Log::debug("Checking bot actions", Some("main()".to_string()), None);
in log :
[blalba@timestmp]
debug = "Checking bot actions",
*/
pub fn trace(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::trace_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
}
pub fn debug(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::debug_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
}
pub fn info(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::info_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
}
pub fn notice(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::notice_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
}
pub fn warn(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::warn_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
}
pub fn error(in_msg: &str, in_module: Option<String>, in_prvmsg: Option<&PrivmsgMessage>) {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::error_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
}
pub fn fatal<'a>(
in_msg: &'a str,
in_module: Option<String>,
in_prvmsg: Option<&PrivmsgMessage>,
) -> &'a str {
let (chnl, chatter) = match in_prvmsg {
Some(prvmsg) => {
//Log::trace(&format!("(#{}) {}: {}", prvmsg.channel_login, prvmsg.sender.name, prvmsg.message_text));
(
Some(prvmsg.channel_login.clone()),
Some(prvmsg.sender.name.clone()),
) // <-- Clone fine atm while we're just working with Strings
}
None => (None, None),
};
Log::fatal_t(
in_msg,
casual_logger::Table::default() //
.str("Channel", &format!("{:?}", chnl))
.str("Chatter", &format!("{:?}", chatter))
.str("Code_Module", &format!("{:?}", in_module)),
);
in_msg
}

View file

@ -15,7 +15,9 @@ use tokio::sync::RwLock;
// Important to use tokios Mutex here since std Mutex doesn't work with async functions // Important to use tokios Mutex here since std Mutex doesn't work with async functions
// use tokio::sync::Mutex; // use tokio::sync::Mutex;
use crate::core::botinstance::{self, botlog, BotInstance}; use crate::core::botinstance::{self, BotInstance};
use crate::core::botlog;
// use std::rc::Rc; // use std::rc::Rc;
// use tokio::sync::RwLock; // use tokio::sync::RwLock;
@ -185,7 +187,7 @@ impl BotActionTrait for Listener {
async fn add_to_bot(self, bot: BotInstance) { async fn add_to_bot(self, bot: BotInstance) {
// println!("Adding action to bot"); // println!("Adding action to bot");
// Log::trace("Adding action to bot"); // Log::trace("Adding action to bot");
botinstance::botlog::trace( botlog::trace(
"Adding action to bot", "Adding action to bot",
Some("BotModules > BotActionTrait > add_to_bot()".to_string()), Some("BotModules > BotActionTrait > add_to_bot()".to_string()),
None, None,
@ -197,7 +199,7 @@ impl BotActionTrait for Listener {
// let modmgr = *modmgr.lock().await; // let modmgr = *modmgr.lock().await;
// println!("Adding action to module manager"); // println!("Adding action to module manager");
// Log::trace("Adding action to module manager"); // Log::trace("Adding action to module manager");
botinstance::botlog::trace( botlog::trace(
"Adding action to module manager", "Adding action to module manager",
Some("BotModules > BotActionTrait > add_to_bot()".to_string()), Some("BotModules > BotActionTrait > add_to_bot()".to_string()),
None, None,

View file

@ -7,7 +7,8 @@ use crate::core::botmodules::bot_actions::actions_util;
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager}; use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
// use crate::core::botinstance::{self, botlog, BotInstance, ChType}; // use crate::core::botinstance::{self, botlog, BotInstance, ChType};
use crate::core::botinstance::{self, ChType}; use crate::core::botinstance::ChType;
use crate::core::botlog;
// use futures::lock::Mutex; // use futures::lock::Mutex;
// use twitch_irc::message::{Badge, PrivmsgMessage}; // use twitch_irc::message::{Badge, PrivmsgMessage};
use twitch_irc::message::PrivmsgMessage; use twitch_irc::message::PrivmsgMessage;
@ -34,7 +35,7 @@ fn adminvector() -> Vec<String> {
// pub fn init(mgr:&mut ModulesManager) // pub fn init(mgr:&mut ModulesManager)
pub async fn init(mgr: Arc<ModulesManager>) { pub async fn init(mgr: Arc<ModulesManager>) {
// println!("Went into Identiy Module init"); // println!("Went into Identiy Module init");
botinstance::botlog::trace( botlog::trace(
"Went into Identiy Module init", "Went into Identiy Module init",
Some("identity.rs > init()".to_string()), Some("identity.rs > init()".to_string()),
None, None,
@ -61,7 +62,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
async fn cmd_promote(bot: BotAR, msg: PrivmsgMessage) { async fn cmd_promote(bot: BotAR, msg: PrivmsgMessage) {
//println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); //println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
// println!("Called cmd promote"); // println!("Called cmd promote");
botinstance::botlog::trace( botlog::trace(
"Called cmd promote", "Called cmd promote",
Some("identity.rs > cmd_prommote()".to_string()), Some("identity.rs > cmd_prommote()".to_string()),
Some(&msg), Some(&msg),
@ -94,7 +95,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
*/ */
// println!("{}",msg.message_text); // println!("{}",msg.message_text);
botinstance::botlog::trace( botlog::trace(
&format!("Twich Message > {}", msg.message_text), &format!("Twich Message > {}", msg.message_text),
Some("identity.rs > cmd_promote()".to_string()), Some("identity.rs > cmd_promote()".to_string()),
None, None,
@ -144,7 +145,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
let rslt = match targetusr { let rslt = match targetusr {
Some(targetusr) => { Some(targetusr) => {
botinstance::botlog::debug( botlog::debug(
// &format!("running promote()"), // &format!("running promote()"),
"running promote()", "running promote()",
Some("identity.rs > cmd_promote()".to_string()), Some("identity.rs > cmd_promote()".to_string()),
@ -170,7 +171,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
} }
None => { None => {
botinstance::botlog::debug( botlog::debug(
// &format!("No Targer User argument"), // &format!("No Targer User argument"),
"No Targer User argument", "No Targer User argument",
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
@ -188,7 +189,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::Success(a) => { ChangeResult::Success(a) => {
// println!("Succesfully promoted : {a} ;"); // println!("Succesfully promoted : {a} ;");
let outmsg = &format!("o7 Successfully promoted : {a}"); let outmsg = &format!("o7 Successfully promoted : {a}");
botinstance::botlog::debug( botlog::debug(
outmsg, outmsg,
Some("identity.rs > cmd_prommote()".to_string()), Some("identity.rs > cmd_prommote()".to_string()),
Some(&msg), Some(&msg),
@ -203,7 +204,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::Failed(a) => { ChangeResult::Failed(a) => {
// println!("Failed to promote : {a} ; "); // println!("Failed to promote : {a} ; ");
let outmsg = &format!("PoroSad failed to promote : {a}"); let outmsg = &format!("PoroSad failed to promote : {a}");
botinstance::botlog::debug( botlog::debug(
outmsg, outmsg,
Some("identity.rs > cmd_prommote()".to_string()), Some("identity.rs > cmd_prommote()".to_string()),
Some(&msg), Some(&msg),
@ -218,7 +219,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::NoChange(a) => { ChangeResult::NoChange(a) => {
// println!("No Changes Made : {a} ; "); // println!("No Changes Made : {a} ; ");
let outmsg = &format!("uuh No Promotion Change : {a}"); let outmsg = &format!("uuh No Promotion Change : {a}");
botinstance::botlog::debug( botlog::debug(
outmsg, outmsg,
Some("identity.rs > cmd_prommote()".to_string()), Some("identity.rs > cmd_prommote()".to_string()),
Some(&msg), Some(&msg),
@ -486,7 +487,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
*/ */
botinstance::botlog::trace( botlog::trace(
// &format!("End of cmd_promote()"), // &format!("End of cmd_promote()"),
"End of cmd_promote()", "End of cmd_promote()",
Some("identity.rs > cmd_prommote()".to_string()), Some("identity.rs > cmd_prommote()".to_string()),
@ -527,7 +528,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// async fn cmd_demote(mut _chat:Arc<Mutex<BotInstance>>,_msg:PrivmsgMessage) { // async fn cmd_demote(mut _chat:Arc<Mutex<BotInstance>>,_msg:PrivmsgMessage) {
async fn cmd_demote(bot: BotAR, msg: PrivmsgMessage) { async fn cmd_demote(bot: BotAR, msg: PrivmsgMessage) {
// println!("Called cmd demote"); // println!("Called cmd demote");
botinstance::botlog::debug( botlog::debug(
"Called cmd demote", "Called cmd demote",
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
Some(&msg), Some(&msg),
@ -669,7 +670,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
let rslt = match targetusr { let rslt = match targetusr {
Some(targetusr) => { Some(targetusr) => {
botinstance::botlog::debug( botlog::debug(
// &format!("running demote()"), // &format!("running demote()"),
"running demote()", "running demote()",
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
@ -688,7 +689,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
} }
None => { None => {
botinstance::botlog::debug( botlog::debug(
// &format!("No Targer User argument"), // &format!("No Targer User argument"),
"No Targer User argument", "No Targer User argument",
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
@ -746,7 +747,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::Success(a) => { ChangeResult::Success(a) => {
// println!("Succesfully promoted : {a} ;"); // println!("Succesfully promoted : {a} ;");
let outmsg = &format!("o7 Successfully demoted : {a}"); let outmsg = &format!("o7 Successfully demoted : {a}");
botinstance::botlog::debug( botlog::debug(
outmsg, outmsg,
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
Some(&msg), Some(&msg),
@ -761,7 +762,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::Failed(a) => { ChangeResult::Failed(a) => {
// println!("Failed to promote : {a} ; "); // println!("Failed to promote : {a} ; ");
let outmsg = &format!("PoroSad failed to demote : {a}"); let outmsg = &format!("PoroSad failed to demote : {a}");
botinstance::botlog::debug( botlog::debug(
outmsg, outmsg,
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
Some(&msg), Some(&msg),
@ -776,7 +777,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::NoChange(a) => { ChangeResult::NoChange(a) => {
// println!("No Changes Made : {a} ; "); // println!("No Changes Made : {a} ; ");
let outmsg = &format!("uuh No Demotion Change : {a}"); let outmsg = &format!("uuh No Demotion Change : {a}");
botinstance::botlog::debug( botlog::debug(
outmsg, outmsg,
Some("identity.rs > cmd_demote()".to_string()), Some("identity.rs > cmd_demote()".to_string()),
Some(&msg), Some(&msg),
@ -813,7 +814,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// async fn getroles(bot:Arc<Mutex<BotInstance>>,msg:PrivmsgMessage) { // async fn getroles(bot:Arc<Mutex<BotInstance>>,msg:PrivmsgMessage) {
async fn getroles(bot: BotAR, msg: PrivmsgMessage) { async fn getroles(bot: BotAR, msg: PrivmsgMessage) {
// println!("Called cmd getroles"); // println!("Called cmd getroles");
botinstance::botlog::debug( botlog::debug(
"Called cmd getroles", "Called cmd getroles",
Some("identity.rs > cmd_getroles()".to_string()), Some("identity.rs > cmd_getroles()".to_string()),
Some(&msg), Some(&msg),
@ -888,21 +889,21 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// let a = bot.get_identity(); // let a = bot.get_identity();
let botlock = bot.read().await; let botlock = bot.read().await;
// println!("botlock read"); // println!("botlock read");
botinstance::botlog::trace( botlog::trace(
"botlock read", "botlock read",
Some("identity.rs > init > getroles()".to_string()), Some("identity.rs > init > getroles()".to_string()),
Some(&msg), Some(&msg),
); );
let idlock = botlock.get_identity(); let idlock = botlock.get_identity();
// println!("got identity"); // println!("got identity");
botinstance::botlog::trace( botlog::trace(
"got identity", "got identity",
Some("identity.rs > init > getroles()".to_string()), Some("identity.rs > init > getroles()".to_string()),
Some(&msg), Some(&msg),
); );
let idlock = idlock.read().await; // <-- 02.12 - Latest where it gest stuck - before or at this point let idlock = idlock.read().await; // <-- 02.12 - Latest where it gest stuck - before or at this point
// println!("id lock"); // println!("id lock");
botinstance::botlog::trace( botlog::trace(
"id lock", "id lock",
Some("identity.rs > init > getroles()".to_string()), Some("identity.rs > init > getroles()".to_string()),
Some(&msg), Some(&msg),
@ -1003,7 +1004,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// let sproles = idlock.getspecialuserroles(String::from(targetuser),).await; // let sproles = idlock.getspecialuserroles(String::from(targetuser),).await;
// println!("Retrieved User Roles >> {:?}",sproles); // println!("Retrieved User Roles >> {:?}",sproles);
botinstance::botlog::debug( botlog::debug(
&format!("User roles of Target Chatter >> {:?}", sproles), &format!("User roles of Target Chatter >> {:?}", sproles),
Some("identity.rs > init > getroles()".to_string()), Some("identity.rs > init > getroles()".to_string()),
Some(&msg), Some(&msg),
@ -1011,7 +1012,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// # I believe at this stage I still have botlock active // # I believe at this stage I still have botlock active
botinstance::botlog::debug( botlog::debug(
// &format!("Evaluating special roles"), // &format!("Evaluating special roles"),
"Evaluating special roles", "Evaluating special roles",
Some("identity.rs > init > getroles()".to_string()), Some("identity.rs > init > getroles()".to_string()),
@ -1091,7 +1092,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// let a = bot.identity.getuserroles(String::from("ModulatingForce"), Some(ChType::Channel(String::from("ModulatingForcebot")))); // let a = bot.identity.getuserroles(String::from("ModulatingForce"), Some(ChType::Channel(String::from("ModulatingForcebot"))));
// println!("{:?}",a); // println!("{:?}",a);
botinstance::botlog::debug( botlog::debug(
&format!("Chat Say Reply message : {:?}", outmsg), &format!("Chat Say Reply message : {:?}", outmsg),
Some("identity.rs > init > getroles()".to_string()), Some("identity.rs > init > getroles()".to_string()),
Some(&msg), Some(&msg),
@ -1102,7 +1103,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
} }
// println!("End of Init MOdule add"); // println!("End of Init MOdule add");
botinstance::botlog::trace( botlog::trace(
"End of Init MOdule add", "End of Init MOdule add",
Some("identity.rs > init ".to_string()), Some("identity.rs > init ".to_string()),
None, None,
@ -1215,7 +1216,7 @@ impl IdentityManager {
srulock srulock
.entry(trgchatter.clone()) .entry(trgchatter.clone())
.or_insert(Arc::new(RwLock::new(vec![]))); .or_insert(Arc::new(RwLock::new(vec![])));
botinstance::botlog::trace( botlog::trace(
&format!( &format!(
"Ensuring User in Roles {:?}", "Ensuring User in Roles {:?}",
srulock.entry(trgchatter.clone()) srulock.entry(trgchatter.clone())
@ -1240,7 +1241,7 @@ impl IdentityManager {
// [ ] Check what Badges in PrivmsgMessage // [ ] Check what Badges in PrivmsgMessage
// println!{"Checking within PRVMSG"}; // println!{"Checking within PRVMSG"};
botinstance::botlog::debug( botlog::debug(
"Checking within PRVMSG", "Checking within PRVMSG",
Some("identity.rs > can_user_run_PRVMSG()".to_string()), Some("identity.rs > can_user_run_PRVMSG()".to_string()),
// Some(&msg), // Some(&msg),
@ -1327,7 +1328,7 @@ impl IdentityManager {
cmdreqroles: Vec<UserRole>, // ) -> Result<Permissible,Box<dyn Error>> { cmdreqroles: Vec<UserRole>, // ) -> Result<Permissible,Box<dyn Error>> {
) -> (Permissible, ChangeResult) { ) -> (Permissible, ChangeResult) {
// println!{"Checking within can_user_run()"}; // println!{"Checking within can_user_run()"};
botinstance::botlog::debug( botlog::debug(
&format!( &format!(
"Checking within can_user_run() : "Checking within can_user_run() :
usr : {} ; channel : {:?} ; badge : {:?} ; cmdreqroles : {:?}", usr : {} ; channel : {:?} ; badge : {:?} ; cmdreqroles : {:?}",
@ -1410,7 +1411,7 @@ impl IdentityManager {
// [x] If not, assign them UserRole::Mod(channelname::ChType) // [x] If not, assign them UserRole::Mod(channelname::ChType)
Some(ChatBadge::Mod) => { Some(ChatBadge::Mod) => {
// println!("Mod Chatbadge detected"); // println!("Mod Chatbadge detected");
botinstance::botlog::info( botlog::info(
"Mod Chatbadge detected", "Mod Chatbadge detected",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1423,7 +1424,7 @@ impl IdentityManager {
// match self.special_roles_users.get_mut(&usr.to_lowercase()) { // match self.special_roles_users.get_mut(&usr.to_lowercase()) {
// match self.special_roles_users.get(&usr.to_lowercase()) { // match self.special_roles_users.get(&usr.to_lowercase()) {
// println!("Creating clone"); // println!("Creating clone");
botinstance::botlog::trace( botlog::trace(
"Creating arc clone", "Creating arc clone",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1433,7 +1434,7 @@ impl IdentityManager {
let roleslock = Arc::clone(&self.special_roles_users); let roleslock = Arc::clone(&self.special_roles_users);
// println!("Read lock on : Special_Roles_User"); // <-- after this is slightly different between working and problem // println!("Read lock on : Special_Roles_User"); // <-- after this is slightly different between working and problem
botinstance::botlog::trace( botlog::trace(
"Read lock on : Special_Roles_User", "Read lock on : Special_Roles_User",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1468,7 +1469,7 @@ impl IdentityManager {
// Do nothing when theh have a mod badge and have either a supmod or mod badge for the channel // 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"); // println!("Already a mod in roles");
botinstance::botlog::trace( botlog::trace(
"Already a mod in roles", "Already a mod in roles",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1477,13 +1478,13 @@ impl IdentityManager {
_ => { _ => {
// In the event they have a mod badge , are running a bot command, but don't have a channel mod role yet... // 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"); // println!("lock created > adding with a mod role o7");
botinstance::botlog::trace( botlog::trace(
"lock created > adding with a mod role o7", "lock created > adding with a mod role o7",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
); );
// botinstance::botlog::notice("Assigning ModRole to Chatter", // botlog::notice("Assigning ModRole to Chatter",
// Some("identity.rs > can_user_run()".to_string()), None); // Some("identity.rs > can_user_run()".to_string()), None);
let mut roleslock = roleslock; let mut roleslock = roleslock;
@ -1510,7 +1511,7 @@ impl IdentityManager {
// [x] If cmdreqroles includes UserRole::Mod("") , checks if chatter has UserRole::Mod(channelname::ChType) or UserRole::SupMod(channelname::ChType) to determine if Ok(Permissible::Allow) // [x] If cmdreqroles includes UserRole::Mod("") , checks if chatter has UserRole::Mod(channelname::ChType) or UserRole::SupMod(channelname::ChType) to determine if Ok(Permissible::Allow)
// println!("cmd required roles : {:?}",cmdreqroles); // println!("cmd required roles : {:?}",cmdreqroles);
botinstance::botlog::trace( botlog::trace(
&format!("cmd required roles : {:?}", cmdreqroles), &format!("cmd required roles : {:?}", cmdreqroles),
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1524,7 +1525,7 @@ impl IdentityManager {
// } // }
// println!("Command requires Mod Role"); // println!("Command requires Mod Role");
botinstance::botlog::trace( botlog::trace(
"Command requires Mod Role", "Command requires Mod Role",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1542,7 +1543,7 @@ impl IdentityManager {
.get(&usr.to_lowercase()) .get(&usr.to_lowercase())
{ {
// println!("Special roles found for user"); // println!("Special roles found for user");
botinstance::botlog::trace( botlog::trace(
"Special roles found for user", "Special roles found for user",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1555,7 +1556,7 @@ impl IdentityManager {
{ {
// return Ok(Permissible::Allow); // return Ok(Permissible::Allow);
// println!("Special roles found for user : A mod idenfified "); // println!("Special roles found for user : A mod idenfified ");
botinstance::botlog::trace( botlog::trace(
"> Special Role Identified : Mod ", "> Special Role Identified : Mod ",
Some("identity.rs > can_user_run()".to_string()), Some("identity.rs > can_user_run()".to_string()),
None, None,
@ -1592,7 +1593,7 @@ impl IdentityManager {
// [x] If cmdreqroles includes UserRole::BotAdmin and chatter has UserRole::BotAdmin , Ok(Permissible::Allow) // [x] If cmdreqroles includes UserRole::BotAdmin and chatter has UserRole::BotAdmin , Ok(Permissible::Allow)
// println!("Eval cmdreqroles with botadmin : {}",cmdreqroles.contains(&UserRole::BotAdmin)); // println!("Eval cmdreqroles with botadmin : {}",cmdreqroles.contains(&UserRole::BotAdmin));
botinstance::botlog::trace( botlog::trace(
&format!( &format!(
"Eval cmdreqroles with botadmin : {}", "Eval cmdreqroles with botadmin : {}",
cmdreqroles.contains(&UserRole::BotAdmin) cmdreqroles.contains(&UserRole::BotAdmin)
@ -1603,7 +1604,7 @@ impl IdentityManager {
if cmdreqroles.contains(&UserRole::BotAdmin) { if cmdreqroles.contains(&UserRole::BotAdmin) {
// println!("special roles get : {:?}",(&*self).special_roles_users.read().await.get(&usr.to_lowercase())); // println!("special roles get : {:?}",(&*self).special_roles_users.read().await.get(&usr.to_lowercase()));
botinstance::botlog::trace( botlog::trace(
&format!( &format!(
"special roles get : {:?}", "special roles get : {:?}",
// (&*self) // (&*self)
@ -1631,7 +1632,7 @@ impl IdentityManager {
"special roles contains BotAdmin: {}", "special roles contains BotAdmin: {}",
a.read().await.contains(&UserRole::BotAdmin) a.read().await.contains(&UserRole::BotAdmin)
); );
botinstance::botlog::trace( botlog::trace(
&format!( &format!(
"special roles contains BotAdmin: {}", "special roles contains BotAdmin: {}",
a.read().await.contains(&UserRole::BotAdmin) a.read().await.contains(&UserRole::BotAdmin)
@ -1662,7 +1663,7 @@ impl IdentityManager {
channel: Option<ChType>, channel: Option<ChType>,
trg_role: Option<UserRole>, trg_role: Option<UserRole>,
) -> ChangeResult { ) -> ChangeResult {
botinstance::botlog::trace( botlog::trace(
&format!( &format!(
"IN VARS for promote() : auth : {} ; authbadge : {:?} ; trg : {} ; Channel {:?} ; {:?}", "IN VARS for promote() : auth : {} ; authbadge : {:?} ; trg : {} ; Channel {:?} ; {:?}",
authorizer,authorizer_badge,trgchatter,channel,trg_role), authorizer,authorizer_badge,trgchatter,channel,trg_role),
@ -1929,7 +1930,7 @@ impl IdentityManager {
// Some("identity.rs > promote()".to_string()), // Some("identity.rs > promote()".to_string()),
// None, // None,
// ); // );
botinstance::botlog::warn( botlog::warn(
"Code Warning : add handing for other trgusrroles", "Code Warning : add handing for other trgusrroles",
Some("identity.rs > promote()".to_string()), Some("identity.rs > promote()".to_string()),
None, None,
@ -2265,7 +2266,7 @@ impl IdentityManager {
// Some("identity.rs > promote()".to_string()), // Some("identity.rs > promote()".to_string()),
// None, // None,
// ); // );
botinstance::botlog::warn( botlog::warn(
"Runtime reached undeveloped code", "Runtime reached undeveloped code",
Some("identity.rs > promote()".to_string()), Some("identity.rs > promote()".to_string()),
None, None,
@ -2283,7 +2284,7 @@ impl IdentityManager {
) -> ChangeResult { ) -> ChangeResult {
// botinstance::botlog::trace(&format!("IN VARS for demote() : Authorizer : {:?} ; Target Chatter : {} ; Target Channel : {:?} ; Targer Role {:?}", // botinstance::botlog::trace(&format!("IN VARS for demote() : Authorizer : {:?} ; Target Chatter : {} ; Target Channel : {:?} ; Targer Role {:?}",
// authorizer,trgchatter,channel,trg_role), // authorizer,trgchatter,channel,trg_role),
botinstance::botlog::trace(&format!("IN VARS for demote() : Authorizer : {:?} ; Target Chatter : {} ; Target Channel : {:?}", botlog::trace(&format!("IN VARS for demote() : Authorizer : {:?} ; Target Chatter : {} ; Target Channel : {:?}",
authorizer,trgchatter,channel), Some("identity.rs > demote()".to_string()), None); authorizer,trgchatter,channel), Some("identity.rs > demote()".to_string()), None);
Log::flush(); Log::flush();
@ -2403,7 +2404,7 @@ impl IdentityManager {
// botinstance::botlog::warn(&format!("Potential Unhandled Demotion Condition : Consider explicitely adding in for better handling"), // botinstance::botlog::warn(&format!("Potential Unhandled Demotion Condition : Consider explicitely adding in for better handling"),
// Some("identity.rs > demote()".to_string()), None); // Some("identity.rs > demote()".to_string()), None);
botinstance::botlog::warn("Potential Unhandled Demotion Condition : Consider explicitely adding in for better handling", botlog::warn("Potential Unhandled Demotion Condition : Consider explicitely adding in for better handling",
Some("identity.rs > demote()".to_string()), None); Some("identity.rs > demote()".to_string()), None);
Log::flush(); Log::flush();
ChangeResult::Failed(String::from("Did not meet criteria to demote succesfully")) ChangeResult::Failed(String::from("Did not meet criteria to demote succesfully"))
@ -2420,7 +2421,7 @@ impl IdentityManager {
*/ */
// [ ] !!! TODO: I don't think below is evaluating by given channel // [ ] !!! TODO: I don't think below is evaluating by given channel
botinstance::botlog::debug( botlog::debug(
&format!( &format!(
"IN VARS > chattername {} ; channel {:?}", "IN VARS > chattername {} ; channel {:?}",
chattername, channel chattername, channel
@ -2467,14 +2468,14 @@ impl IdentityManager {
Some(channel) => { Some(channel) => {
// let eval = a.read().await.contains(&UserRole::Mod(channel)); // let eval = a.read().await.contains(&UserRole::Mod(channel));
// let eval = a.read().await.contains(&UserRole::SupMod(channel)); // let eval = a.read().await.contains(&UserRole::SupMod(channel));
botinstance::botlog::debug( botlog::debug(
&format!("INTERNAL > All Roles found {:?}", &a), &format!("INTERNAL > All Roles found {:?}", &a),
Some("IdentityManager > getspecialuserroles()".to_string()), Some("IdentityManager > getspecialuserroles()".to_string()),
None, None,
); );
// a.read().await.contains(&UserRole::BotAdmin) // a.read().await.contains(&UserRole::BotAdmin)
botinstance::botlog::trace( botlog::trace(
&format!( &format!(
"INTERNAL > eval special roles contains botadmin : {:?}", "INTERNAL > eval special roles contains botadmin : {:?}",
a.read().await.contains(&UserRole::BotAdmin) a.read().await.contains(&UserRole::BotAdmin)
@ -2514,7 +2515,7 @@ impl IdentityManager {
} }
} }
botinstance::botlog::debug( botlog::debug(
&format!("OUT > evalsproles {:?}", &evalsproles), &format!("OUT > evalsproles {:?}", &evalsproles),
Some("IdentityManager > getspecialuserroles()".to_string()), Some("IdentityManager > getspecialuserroles()".to_string()),
None, None,

View file

@ -3,7 +3,8 @@ use tokio::sync::RwLock;
use casual_logger::{Extension, Level, Log}; use casual_logger::{Extension, Level, Log};
use bot_lib::core::botinstance::{BotInstance,botlog}; use bot_lib::core::botinstance::BotInstance;
use bot_lib::core::botlog;
use bot_lib::core::botmodules; use bot_lib::core::botmodules;
pub type BotAR = Arc<RwLock<BotInstance>>; pub type BotAR = Arc<RwLock<BotInstance>>;
@ -48,7 +49,6 @@ pub async fn main() {
bot.runner().await; bot.runner().await;
let pstr = let pstr = botlog::fatal("ERROR : EXIT Game loop", Some("main()".to_string()), None);
botlog::fatal("ERROR : EXIT Game loop", Some("main()".to_string()), None);
panic!("{}", pstr); panic!("{}", pstr);
} }

View file

@ -20,5 +20,4 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// this is achieved by calling submodules that also have fn init() defined // this is achieved by calling submodules that also have fn init() defined
experiments::init(mgr).await experiments::init(mgr).await
} }

View file

@ -10,13 +10,12 @@
*/ */
use std::sync::Arc;
use rand::Rng; use rand::Rng;
use std::sync::Arc;
use twitch_irc::message::PrivmsgMessage; use twitch_irc::message::PrivmsgMessage;
use crate::core::botinstance::botlog; use crate::core::botlog;
use crate::core::botmodules::bot_actions::actions_util::{self, BotAR}; use crate::core::botmodules::bot_actions::actions_util::{self, BotAR};
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager}; use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
@ -24,8 +23,6 @@ use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, M
use crate::core::identity; use crate::core::identity;
pub async fn init(mgr: Arc<ModulesManager>) { pub async fn init(mgr: Arc<ModulesManager>) {
// 1. Define the BotAction // 1. Define the BotAction
let botc1 = BotCommand { let botc1 = BotCommand {
module: BotModule(String::from("experiments001")), module: BotModule(String::from("experiments001")),
@ -39,7 +36,6 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// 2. Add the BotAction to ModulesManager // 2. Add the BotAction to ModulesManager
botc1.add_to_modmgr(Arc::clone(&mgr)).await; botc1.add_to_modmgr(Arc::clone(&mgr)).await;
// 1. Define the BotAction // 1. Define the BotAction
let list1 = Listener { let list1 = Listener {
module: BotModule(String::from("experiments001")), module: BotModule(String::from("experiments001")),
@ -50,11 +46,9 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// 2. Add the BotAction to ModulesManager // 2. Add the BotAction to ModulesManager
list1.add_to_modmgr(Arc::clone(&mgr)).await; list1.add_to_modmgr(Arc::clone(&mgr)).await;
} }
async fn good_girl(bot: BotAR, msg: PrivmsgMessage) { async fn good_girl(bot: BotAR, msg: PrivmsgMessage) {
// [ ] Uses gen_ratio() to output bool based on a ratio probability . // [ ] 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) // - 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 // - More Info : https://rust-random.github.io/rand/rand/trait.Rng.html#method.gen_ratio
@ -62,18 +56,15 @@ async fn good_girl(bot: BotAR, msg: PrivmsgMessage) {
if msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase() if msg.sender.name.to_lowercase() == "ModulatingForce".to_lowercase()
|| msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase() || msg.sender.name.to_lowercase() == "mzNToRi".to_lowercase()
{ {
botlog::debug( botlog::debug(
"Good Girl Detected > Pausechamp", "Good Girl Detected > Pausechamp",
Some("experiments > goodgirl()".to_string()), Some("experiments > goodgirl()".to_string()),
Some(&msg), Some(&msg),
); );
let rollwin = rand::thread_rng().gen_ratio(1, 8); let rollwin = rand::thread_rng().gen_ratio(1, 8);
if rollwin { if rollwin {
botlog::debug( botlog::debug(
"Oh that's a good girl!", "Oh that's a good girl!",
Some("experiments > goodgirl()".to_string()), Some("experiments > goodgirl()".to_string()),
@ -90,7 +81,6 @@ async fn good_girl(bot: BotAR, msg: PrivmsgMessage) {
.chat .chat
.say_in_reply_to(&msg, String::from("GoodGirl xdd ")) .say_in_reply_to(&msg, String::from("GoodGirl xdd "))
.await; .await;
} }
} }
} }