From da3ce920bfc6a5e0fe1d00427a10501afbf14da2 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:23:27 -0500 Subject: [PATCH] 20240201 - latest issue --- src/core/botinstance.rs | 26 ++++++++++++++++---------- src/core/identity.rs | 4 ++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs index 020185f..32e44af 100644 --- a/src/core/botinstance.rs +++ b/src/core/botinstance.rs @@ -305,7 +305,7 @@ impl BotInstance // async fn listener_main_prvmsg(&mut self,msg:PrivmsgMessage) -> () { - async fn listener_main_prvmsg(&self,msg:&PrivmsgMessage) -> () { + async fn listener_main_prvmsg(&mut self,msg:&PrivmsgMessage) -> () { // println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); @@ -369,13 +369,15 @@ impl BotInstance // match self.botmgrs.identity.to_owned().can_user_run_PRVMSG(&msg, c.required_roles.clone()) { // match self.botmgrs.identity.can_user_run_PRVMSG(&msg, c.required_roles.clone()) { // let a = match self.botmgrs.identity.clone().can_user_run_PRVMSG(&msg, c.required_roles.clone()) { - match self.botmgrs.identity.clone().can_user_run_PRVMSG(&msg, c.required_roles.clone()) { + // match self.botmgrs.identity.clone().can_user_run_PRVMSG(&msg, c.required_roles.clone()) { + match self.botmgrs.identity.can_user_run_PRVMSG(&msg, c.required_roles.clone()) { // Ok(Permissible::Allow) => (), Permissible::Allow => { println!("Executed as permissible"); // c.execute(self.botmgrs.clone(), msg.clone()).await; // c.execute(self.botmgrs, msg.clone()).await; // Some((BotAction::C(c),msg.clone())) + // Some((msg,self)) Some(msg) //Some(BotAction::C(*c)) //Some(String::from("Hello")) @@ -383,6 +385,7 @@ impl BotInstance Permissible::Block => { println!("User Not allowed to run command"); // None::<(BotAction,PrivmsgMessage)> + // None::<(&PrivmsgMessage,&mut BotInstance)> None::<&PrivmsgMessage> //None //Some(String::from("Hello")) @@ -406,14 +409,17 @@ impl BotInstance match b { Some(b) => { // a.execute(self.botmgrs.clone(), b.clone()).await; // This compiles but issue - botmgrs aren't updating - a.execute(self.botmgrs, b.clone()).await; // This throws the following - /* - error[E0507]: cannot move out of `self.botmgrs` which is behind a shared reference - --> src\core\botinstance.rs:409:35 - | - 409 | a.execute(self.botmgrs, b.clone()).await; // This throws - | ^^^^^^^^^^^^ move occurs because `self.botmgrs` has type `BotManagers`, which does not implement the `Copy` trait - */ + // a.execute(self.botmgrs, b.clone()).await; // This throws the following + // /* + // error[E0507]: cannot move out of `self.botmgrs` which is behind a shared reference + // --> src\core\botinstance.rs:409:35 + // | + // 409 | a.execute(self.botmgrs, b.clone()).await; // This throws + // | ^^^^^^^^^^^^ move occurs because `self.botmgrs` has type `BotManagers`, which does not implement the `Copy` trait + // */ + let (msg) = b; + // a.execute(self.botmgrs.clone(), msg.clone()).await; + a.execute(self.botmgrs, msg.clone()).await; } None => (), } diff --git a/src/core/identity.rs b/src/core/identity.rs index a6c6337..5485879 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -306,7 +306,7 @@ impl IdentityManager { // [ ] Maybe I should create a can_user_run version that simply takes PrvMsg, but then calls can_user_run directly // pub fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Result> - pub fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Permissible + pub fn can_user_run_PRVMSG(&mut self,msg:&PrivmsgMessage,cmdreqroles:Vec) -> Permissible { // println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text); @@ -344,7 +344,7 @@ impl IdentityManager { Permissible::Block } - pub fn can_user_run(mut self, + pub fn can_user_run(&mut self, usr:String, channelname:ChType, chat_badge:ChatBadge,