Format Cleanup #18

Merged
modulatingforce merged 10 commits from format-cleanup into main 2024-03-02 17:30:29 -05:00
6 changed files with 124 additions and 1298 deletions
Showing only changes of commit e86b051ff3 - Show all commits

View file

@ -4,13 +4,13 @@ pub mod actions_util {
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use tokio::sync::{Mutex, RwLock};
use twitch_irc::message::PrivmsgMessage;
use crate::core::botinstance::BotInstance;
pub type BotAM = Arc<Mutex<BotInstance>>;
pub type BotAR = Arc<RwLock<BotInstance>>;

View file

@ -16,7 +16,7 @@ use casual_logger::Log;
use crate::core::ratelimiter::RateLimiter;
use crate::core::botmodules::bot_actions::actions_util::BotAR;
use crate::core::bot_actions::actions_util::BotAR;
use crate::core::botmodules::ModulesManager;
use crate::core::identity::{ChangeResult, IdentityManager, Permissible};
@ -142,7 +142,7 @@ impl BotInstance {
ServerMessage::Privmsg(msg) => {
botlog::debug(
format!(
"[Twitch Chat] > {} @ #{}: {}",
"[Twitch Chat > {}] > {}: {}",
msg.channel_login, msg.sender.name, msg.message_text
)
.as_str(),

View file

@ -36,7 +36,7 @@ use crate::core::botinstance::{BotInstance, ChType};
use crate::core::botlog;
use crate::core::identity;
pub use crate::core::bot_actions;
use crate::core::bot_actions;
pub use ChType::Channel;
pub use ModType::BotModule;
@ -168,23 +168,20 @@ botactions
impl ModulesManager {
pub async fn init() -> Arc<ModulesManager> {
let mgr = ModulesManager {
statusdb: Arc::new(RwLock::new(HashMap::new())),
botactions: Arc::new(RwLock::new(HashMap::new())),
};
// :: [x] initialize core modules
botlog::debug(
botlog::trace(
"ModulesManager > init() > Adding modules",
Some("ModulesManager > init()".to_string()),
None,
);
let mgrarc = Arc::new(mgr);
// 1. load core modules
crate::core::identity::init(Arc::clone(&mgrarc)).await;
@ -223,7 +220,6 @@ impl ModulesManager {
}
pub async fn add_botaction(&self, in_module: ModType, in_action: BotAction) {
botlog::trace(
"Add botaction called",
Some("ModulesManager > init()".to_string()),
@ -247,11 +243,9 @@ impl ModulesManager {
// Check All Other BotAction Command Names & Aliases to ensure they don't conflict
async fn find_conflict_module(mgr: &ModulesManager, act: &BotAction) -> Option<ModType> {
if let BotAction::C(incmd) = act {
let actdb = mgr.botactions.read().await;
for (module, moduleactions) in &(*actdb) {
for modact in moduleactions.iter() {
if let BotAction::C(dbcmd) = &modact {
@ -262,13 +256,12 @@ impl ModulesManager {
if incmd.command.to_lowercase() == dbcmd.command.to_lowercase() {
// Returning State - with the identified module
return Some(module.clone()); // works
}
for a in &dbcmd.alias {
if incmd.command.to_lowercase() == a.to_lowercase() {
// Returning State - with the identified module
return Some(module.clone()); // works
}
}
@ -278,14 +271,14 @@ impl ModulesManager {
for inalias in &incmd.alias {
if inalias.to_lowercase() == dbcmd.command.to_lowercase() {
// Returning State - with the identified module
return Some(module.clone()); // works
}
for a in &dbcmd.alias {
if inalias.to_lowercase() == a.to_lowercase() {
// Returning State - with the identified module
return Some(module.clone()); // works
}
}
@ -307,21 +300,21 @@ impl ModulesManager {
}
let mut dbt = self.statusdb.write().await;
let statusvector = dbt
.entry(in_module.clone())
.or_insert(Vec::new());
let statusvector = dbt.entry(in_module.clone()).or_insert(Vec::new());
statusvector.push(ModStatusType::Enabled(StatusLvl::Instance)); // Pushes the Module as Enabled at Instance Level
let mut a = self.botactions.write().await;
let modactions = a
.entry(in_module.clone())
.or_insert(Vec::new());
let modactions = a.entry(in_module.clone()).or_insert(Vec::new());
modactions.push(in_action);
botlog::trace(
format!("Modules Manager> add_botaction called - botactions size : {}", modactions.len()).as_str(),
format!(
"Modules Manager> add_botaction called - botactions size : {}",
modactions.len()
)
.as_str(),
Some("ModulesManager > init()".to_string()),
None,
);

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ use twitch_irc::message::PrivmsgMessage;
use crate::core::botlog;
use crate::core::botmodules::bot_actions::actions_util::{self, BotAR};
use crate::core::bot_actions::actions_util::{self, BotAR};
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
use crate::core::identity;

View file

@ -20,7 +20,7 @@ pub async fn main() {
let bot = BotInstance::init().await;
{
botlog::debug("Reading bot actions", Some("main()".to_string()), None);
botlog::trace("Reading bot actions", Some("main()".to_string()), None);
let actsdb = Arc::clone(&bot.botmodules.botactions);
let actsdb_lock = actsdb.read().await;
@ -29,10 +29,10 @@ pub async fn main() {
for act in acts {
let outstr = match act {
botmodules::BotAction::C(b) => {
format!("bot actions: {}", b.command)
format!("bot actions > Command : {}", b.command)
}
botmodules::BotAction::L(l) => {
format!("bot actions: {}", l.name)
format!("bot actions > Listener : {}", l.name)
}
_ => "Not a valid match??".to_string(),
};