introduced BotManagers to BotInstance
This commit is contained in:
parent
50321a7ce0
commit
a6aedb291f
2 changed files with 25 additions and 8 deletions
|
@ -130,16 +130,32 @@ impl Chat {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub struct BotManagers {
|
||||||
|
pub botmodules : ModulesManager,
|
||||||
|
pub identity : IdentityManager,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BotManagers {
|
||||||
|
|
||||||
|
pub fn init() -> BotManagers {
|
||||||
|
BotManagers {
|
||||||
|
botmodules : ModulesManager::init(),
|
||||||
|
identity : IdentityManager::init(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct BotInstance
|
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>,
|
||||||
pub identity : IdentityManager,
|
// pub identity : IdentityManager,
|
||||||
|
pub botmgrs : BotManagers,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,10 +219,11 @@ impl BotInstance
|
||||||
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(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -278,7 +295,7 @@ impl BotInstance
|
||||||
|
|
||||||
// // [ ] 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)
|
// // [ ] 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.botmodules.botactions {
|
for (_m,acts) in &self.botmgrs.botmodules.botactions {
|
||||||
for a in acts {
|
for a in acts {
|
||||||
|
|
||||||
match a {
|
match a {
|
||||||
|
@ -322,7 +339,7 @@ impl BotInstance
|
||||||
// _ => (),
|
// _ => (),
|
||||||
// }
|
// }
|
||||||
|
|
||||||
match self.identity.to_owned().can_user_run_PRVMSG(&msg, c.required_roles.clone()) {
|
match self.botmgrs.identity.to_owned().can_user_run_PRVMSG(&msg, c.required_roles.clone()) {
|
||||||
// Ok(Permissible::Allow) => (),
|
// Ok(Permissible::Allow) => (),
|
||||||
Permissible::Allow => {
|
Permissible::Allow => {
|
||||||
println!("Executed as permissible");
|
println!("Executed as permissible");
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl BotCommand
|
||||||
impl BotActionTrait for BotCommand
|
impl BotActionTrait for BotCommand
|
||||||
{
|
{
|
||||||
fn add_to_bot(self, mut bot:BotInstance) {
|
fn add_to_bot(self, mut bot:BotInstance) {
|
||||||
let mgr = &mut bot.botmodules;
|
let mgr = &mut bot.botmgrs.botmodules;
|
||||||
self.add_to_modmgr(mgr);
|
self.add_to_modmgr(mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ impl BotActionTrait for Listener
|
||||||
{
|
{
|
||||||
fn add_to_bot(self, mut bot:BotInstance) {
|
fn add_to_bot(self, mut bot:BotInstance) {
|
||||||
|
|
||||||
let mgr = &mut bot.botmodules;
|
let mgr = &mut bot.botmgrs.botmodules;
|
||||||
|
|
||||||
self.add_to_modmgr(mgr);
|
self.add_to_modmgr(mgr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue