(cont) BotManagers compile

This commit is contained in:
ModulatingForce 2024-01-31 01:11:45 -05:00
parent a556a5aa89
commit 8a93ef0469

View file

@ -141,14 +141,18 @@ impl Chat {
pub struct BotManagers { pub struct BotManagers {
pub botmodules : ModulesManager, pub botmodules : ModulesManager,
pub identity : IdentityManager, pub identity : IdentityManager,
pub chat : Chat,
} }
impl BotManagers { impl BotManagers {
pub fn init() -> BotManagers { pub fn init(ratelimiters:HashMap<ChType, RateLimiter>,
client:TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>)
-> BotManagers {
BotManagers { BotManagers {
botmodules : ModulesManager::init(), botmodules : ModulesManager::init(),
identity : IdentityManager::init(), identity : IdentityManager::init(),
chat : Chat::init(ratelimiters,client),
} }
} }
} }
@ -158,7 +162,7 @@ pub struct BotInstance
prefix : char, prefix : char,
bot_channel : ChType, bot_channel : ChType,
pub incoming_messages : UnboundedReceiver<ServerMessage>, pub incoming_messages : UnboundedReceiver<ServerMessage>,
pub chat : Chat, // pub chat : Chat,
// pub botmodules : ModulesManager, // pub botmodules : ModulesManager,
twitch_oauth : String, twitch_oauth : String,
pub bot_channels : Vec<ChType>, pub bot_channels : Vec<ChType>,
@ -223,19 +227,19 @@ impl BotInstance
bot_channel : Channel(login_name) , bot_channel : Channel(login_name) ,
incoming_messages : incoming_messages, incoming_messages : incoming_messages,
//client : client, //client : client,
chat : Chat { // chat : Chat {
ratelimiters : ratelimiters, // ratelimiters : ratelimiters,
client : client, // client : client,
} , // } ,
// botmodules : ModulesManager::init(), // botmodules : ModulesManager::init(),
twitch_oauth : oauth_token, twitch_oauth : oauth_token,
bot_channels : botchannels, bot_channels : botchannels,
// identity : IdentityManager::init(), // identity : IdentityManager::init(),
botmgrs : BotManagers::init(), botmgrs : BotManagers::init(ratelimiters,client),
}; };
println!("{:?}",b.chat.ratelimiters); println!("{:?}",b.botmgrs.chat.ratelimiters);
b b
@ -351,7 +355,7 @@ impl BotInstance
// Ok(Permissible::Allow) => (), // Ok(Permissible::Allow) => (),
Permissible::Allow => { Permissible::Allow => {
println!("Executed as permissible"); println!("Executed as permissible");
c.execute(self.chat.clone(), msg.clone()).await; c.execute(self.botmgrs.chat.clone(), msg.clone()).await;
} }
Permissible::Block => println!("User Not allowed to run command"), Permissible::Block => println!("User Not allowed to run command"),
// _ => (), // _ => (),
@ -361,7 +365,7 @@ impl BotInstance
} }
}, },
crate::core::botmodules::BotAction::L(l) => l.execute(self.chat.clone(), msg.clone()).await, crate::core::botmodules::BotAction::L(l) => l.execute(self.botmgrs.chat.clone(), msg.clone()).await,
_ => (), _ => (),
} }