From 9fdb9748136ed8a04d0dd34a31691d758f6ba614 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Tue, 30 Jan 2024 09:13:59 -0500 Subject: [PATCH] (init) identity > promote/demote commands --- src/core/botmodules.rs | 2 ++ src/core/identity.rs | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index 7be3673..7186730 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -199,6 +199,8 @@ impl ModulesManager botactions : act, }; + // initialize core modules + crate::core::identity::init(&mut mgr); // initialize custom crate modules crate::modules::init(&mut mgr); diff --git a/src/core/identity.rs b/src/core/identity.rs index 3c02c88..49a3528 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -24,7 +24,12 @@ pub fn init(mgr:&mut ModulesManager) alias : vec![], // String of alternative names exec_body : actions_util::asyncbox(cmd_promote) , help : String::from("promote"), - required_roles : vec![], + required_roles : vec![ + UserRole::Mod(ChType::Channel(String::new())), + UserRole::SupMod(ChType::Channel(String::new())), + UserRole::Broadcaster, + UserRole::BotAdmin, + ], }.add_to_modmgr(mgr); async fn cmd_promote(mut _chat:botinstance::Chat,_msg:PrivmsgMessage) { @@ -39,7 +44,12 @@ pub fn init(mgr:&mut ModulesManager) alias : vec![], // String of alternative names exec_body : actions_util::asyncbox(cmd_demote) , help : String::from("demote"), - required_roles : vec![], + required_roles : vec![ + UserRole::Mod(ChType::Channel(String::new())), + UserRole::SupMod(ChType::Channel(String::new())), + UserRole::Broadcaster, + UserRole::BotAdmin, + ], }.add_to_modmgr(mgr); @@ -206,23 +216,23 @@ impl IdentityManager { ChatBadge::Mod => { - println!("Mod Chatbadge detected"); + // println!("Mod Chatbadge detected"); - println!("debug special roles : {:?}",self.special_roles_users); - println!("debug usr : {}",&usr.to_lowercase()); + // println!("debug special roles : {:?}",self.special_roles_users); + // println!("debug usr : {}",&usr.to_lowercase()); // let Some((k,v)) = self.special_roles_users.get_key_value(usr); match self.special_roles_users.get_mut(&usr.to_lowercase()) { Some(usrroles) => { - println!("contains mod : {}", usrroles.contains(&UserRole::Mod(channelname.clone()))); - println!("contains supmod : {}", usrroles.contains(&UserRole::SupMod(channelname.clone()))); + // println!("contains mod : {}", usrroles.contains(&UserRole::Mod(channelname.clone()))); + // println!("contains supmod : {}", usrroles.contains(&UserRole::SupMod(channelname.clone()))); if usrroles.contains(&UserRole::Mod(channelname.clone())) || usrroles.contains(&UserRole::SupMod(channelname.clone())) { // Do nothing - this is expected } else { // in this case, they have a ChatBadge::Mod but should have this for the channel usrroles.push(UserRole::Mod(channelname.clone())); - println!("debug special roles : {:?}",self.special_roles_users); + // println!("debug special roles : {:?}",self.special_roles_users); } }, _ => ()