(cont) (cont) (cont)
This commit is contained in:
parent
b2220dc224
commit
e86b051ff3
6 changed files with 124 additions and 1298 deletions
|
@ -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(),
|
||||
|
|
|
@ -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,21 +168,18 @@ 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
|
||||
|
@ -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,9 +243,7 @@ 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) {
|
||||
|
@ -262,7 +256,6 @@ 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 {
|
||||
|
@ -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,
|
||||
);
|
||||
|
|
1335
src/core/identity.rs
1335
src/core/identity.rs
File diff suppressed because it is too large
Load diff
|
@ -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;
|
||||
|
|
|
@ -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(),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue