From ac1559744625f62aae93eef9758c877527c72db8 Mon Sep 17 00:00:00 2001
From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com>
Date: Mon, 29 Jan 2024 06:18:27 -0500
Subject: [PATCH] (init) Identity Module

---
 src/core.rs             |  1 +
 src/core/botinstance.rs | 15 +++++++++++++--
 src/core/identity.rs    | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100644 src/core/identity.rs

diff --git a/src/core.rs b/src/core.rs
index 320ee73..ca51e65 100644
--- a/src/core.rs
+++ b/src/core.rs
@@ -1,6 +1,7 @@
 pub mod botinstance;
 pub mod ratelimiter;
 pub mod botmodules;
+pub mod identity;
 
 // pub fn init() -> ()
 // {
diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs
index c2bff7a..19596bf 100644
--- a/src/core/botinstance.rs
+++ b/src/core/botinstance.rs
@@ -22,6 +22,8 @@ use crate::core::ratelimiter;
 
 use crate::core::botmodules;
 use crate::core::botmodules::ModulesManager;
+use crate::core::identity::IdentityManager;
+
 
 #[derive(Debug, PartialEq, Eq, Hash, Clone)]
 pub enum ChType {
@@ -137,6 +139,7 @@ pub struct BotInstance
     pub botmodules : ModulesManager,
 	twitch_oauth : String,
 	pub bot_channels : Vec<ChType>,
+    pub identity : IdentityManager,
 }
 
 
@@ -203,6 +206,7 @@ impl BotInstance
             botmodules : ModulesManager::init(),
             twitch_oauth : oauth_token,
             bot_channels : botchannels,    
+            identity : IdentityManager::init(),
         };
 
 
@@ -288,19 +292,26 @@ impl BotInstance
 
                         // [x] Check if a bot command based on ...
                         //    [x] prefix + command
+
+                        let mut exec_bot_command = false;
                         if inpt == self.prefix.to_string() + c.command.as_str() {
-                            c.execute(self.chat.clone(), msg.clone()).await;
+                            exec_bot_command = true;
                         } 
 
                         //    [x] prefix + alias
                         for alias in &c.alias {
                             if inpt == self.prefix.to_string() + alias.as_str() {
-                                c.execute(self.chat.clone(), msg.clone()).await;
+                                exec_bot_command = true;
                             } 
                         }
+
+                        if exec_bot_command {
+                            c.execute(self.chat.clone(), msg.clone()).await;
+                        }
                     },
 
                     crate::core::botmodules::BotAction::L(l) => l.execute(self.chat.clone(), msg.clone()).await,
+
                     _ => (),
                 }
             }
diff --git a/src/core/identity.rs b/src/core/identity.rs
new file mode 100644
index 0000000..eca2243
--- /dev/null
+++ b/src/core/identity.rs
@@ -0,0 +1,36 @@
+
+use std::collections::HashMap;
+
+fn adminvector() -> Vec<String> {
+    vec![String::from("ModulatingForce")]
+}
+
+
+enum userRole {
+	Chatter,
+	Mod(String), // String specifies Channel
+	SupMod(String), // String specifies Channel
+	Broadcaster,
+	BotAdmin,
+}
+
+
+pub struct IdentityManager {
+    specialRolesUsers : HashMap<String,Vec<userRole>>,
+} 
+
+
+impl IdentityManager {
+
+    pub fn init() -> IdentityManager {
+        let mut a = HashMap::new();
+        for admn in adminvector() {
+            a.insert(admn.to_lowercase(),vec![userRole::BotAdmin]);
+        };
+
+        IdentityManager {
+            specialRolesUsers : a,
+        }
+    }
+}
+