Working - BotManagers Added

This commit is contained in:
ModulatingForce 2024-01-31 18:36:23 -05:00
commit f8b9cefacb
4 changed files with 36 additions and 28 deletions

View file

@ -137,9 +137,9 @@ impl Chat {
}
#[derive(Clone)]
pub struct BotManagers {
pub botmodules : ModulesManager,
// pub botmodules : ModulesManager,
pub identity : IdentityManager,
pub chat : Chat,
}
@ -150,7 +150,7 @@ impl BotManagers {
client:TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>)
-> BotManagers {
BotManagers {
botmodules : ModulesManager::init(),
// botmodules : ModulesManager::init(),
identity : IdentityManager::init(),
chat : Chat::init(ratelimiters,client),
}
@ -166,7 +166,7 @@ pub struct BotInstance
bot_channel : ChType,
pub incoming_messages : UnboundedReceiver<ServerMessage>,
// pub chat : Chat,
// pub botmodules : ModulesManager,
pub botmodules : ModulesManager,
twitch_oauth : String,
pub bot_channels : Vec<ChType>,
// pub identity : IdentityManager,
@ -234,7 +234,7 @@ impl BotInstance
// ratelimiters : ratelimiters,
// client : client,
// } ,
// botmodules : ModulesManager::init(),
botmodules : ModulesManager::init(),
twitch_oauth : oauth_token,
bot_channels : botchannels,
// identity : IdentityManager::init(),
@ -304,13 +304,13 @@ impl BotInstance
// async fn listener_main_prvmsg(&mut self,msg:PrivmsgMessage) -> () {
async fn listener_main_prvmsg(self,msg:&PrivmsgMessage) -> () {
async fn listener_main_prvmsg(&self,msg:&PrivmsgMessage) -> () {
// println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
// // [ ] Need to run through all Listener Bodies for Enabled Modules for the context of the message (e.g., ModStatus is Enabled in the context for the channel)
for (_m,acts) in &self.botmgrs.botmodules.botactions {
for (_m,acts) in &self.botmodules.botactions {
for a in acts {
match a {
@ -356,11 +356,11 @@ impl BotInstance
// match self.botmgrs.identity.to_owned().can_user_run_PRVMSG(&msg, c.required_roles.clone()) {
// match self.botmgrs.identity.can_user_run_PRVMSG(&msg, c.required_roles.clone()) {
match self.botmgrs.identity.can_user_run_PRVMSG(&msg, c.required_roles.clone()) {
match self.botmgrs.identity.clone().can_user_run_PRVMSG(&msg, c.required_roles.clone()) {
// Ok(Permissible::Allow) => (),
Permissible::Allow => {
println!("Executed as permissible");
c.execute(self.botmgrs.chat.clone(), msg.clone()).await;
c.execute(self.botmgrs.clone(), msg.clone()).await;
}
Permissible::Block => println!("User Not allowed to run command"),
// _ => (),
@ -370,7 +370,7 @@ impl BotInstance
}
},
crate::core::botmodules::BotAction::L(l) => l.execute(self.botmgrs.chat.clone(), msg.clone()).await,
crate::core::botmodules::BotAction::L(l) => l.execute(self.botmgrs.clone(), msg.clone()).await,
_ => (),
}