From 1343093ecd88a3c0ac2657fd3c0e67441aafc3f3 Mon Sep 17 00:00:00 2001
From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com>
Date: Mon, 29 Jan 2024 12:41:26 -0500
Subject: [PATCH] (init) identity > canUserRun()

---
 src/core/identity.rs | 49 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/src/core/identity.rs b/src/core/identity.rs
index 3ad3b68..fbf0fa1 100644
--- a/src/core/identity.rs
+++ b/src/core/identity.rs
@@ -1,6 +1,6 @@
 
 use std::collections::HashMap;
-
+use std::error::Error;
 
 use crate::core::botmodules::{ModulesManager,Listener,BotModule,BotActionTrait, BotCommand};
 use crate::core::botmodules::bot_actions::actions_util;
@@ -8,6 +8,8 @@ use crate::core::botmodules::bot_actions::actions_util;
 use crate::core::botinstance::{self};
 use twitch_irc::message::PrivmsgMessage;
 
+use crate::core::botmodules::ChType;
+
 fn adminvector() -> Vec<String> {
     vec![String::from("ModulatingForce")]
 }
@@ -27,6 +29,8 @@ pub fn init(mgr:&mut ModulesManager)
 
     async fn cmd_promote(mut _chat:botinstance::Chat,_msg:PrivmsgMessage) {
         //println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
+
+
     }
 
     BotCommand {
@@ -53,13 +57,24 @@ pub enum UserRole {
 	SupMod(String), // String specifies Channel
 	Broadcaster,
 	BotAdmin,
+    
 }
 
 
+enum Permissible {
+	Allow,
+	Block
+}
+
 pub struct IdentityManager {
     special_roles_users : HashMap<String,Vec<UserRole>>,
 } 
 
+enum ChatBadge {
+    Broadcaster,
+    Mod,
+}
+
 
 impl IdentityManager {
 
@@ -73,5 +88,37 @@ impl IdentityManager {
             special_roles_users : a,
         }
     }
+
+    pub fn canUserRun(self,
+        usr:String,
+        channelname:ChType,
+        chatBadge:ChatBadge,
+        cmdreqroles:Vec<UserRole>
+        ) -> Result<Permissible,Box<dyn Error>> {
+            /*
+            canUserRun -
+
+            Input : 
+                usr:String,
+                channelname:ChType,
+                chatBadge:ChatBadge,
+                cmdreqroles:Vec<UserRole>
+
+            Output : Result<Permissible,Box<dyn Error>> 
+                Some Possible outcomes : Ok(Permissible::Allow) , Ok(Permissible::Block) 
+
+
+            Description
+                For a Given Chatter (with any special ChatBadge) who ran the Command at a Given Channel , check if that user can
+                run the command based on the given cmdreqroles required by the command
+
+                Inputs and business logic determine if the user can run the command based on the command's required roles
+             */
+
+
+
+
+            Ok(Permissible::Allow)
+        }
 }