From 39cd4ba65e693c2d95444cf4c62505f95a956034 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:43:39 -0500 Subject: [PATCH] Problem - with botmanagers --- src/core/botinstance.rs | 53 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs index 568d4e6..020185f 100644 --- a/src/core/botinstance.rs +++ b/src/core/botinstance.rs @@ -17,6 +17,7 @@ use rand::Rng; +use crate::core::botmodules::BotAction; use crate::core::ratelimiter::RateLimiter; use crate::core::ratelimiter; @@ -313,7 +314,10 @@ impl BotInstance for (_m,acts) in &self.botmodules.botactions { for a in acts { - match a { + // match a { + // let Some((b,msg)) = match a { + let b = match a { + crate::core::botmodules::BotAction::C(c) => { /* @@ -364,27 +368,64 @@ 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()) { // Ok(Permissible::Allow) => (), Permissible::Allow => { println!("Executed as permissible"); - c.execute(self.botmgrs.clone(), msg.clone()).await; + // c.execute(self.botmgrs.clone(), msg.clone()).await; + // c.execute(self.botmgrs, msg.clone()).await; + // Some((BotAction::C(c),msg.clone())) + Some(msg) + //Some(BotAction::C(*c)) + //Some(String::from("Hello")) } - Permissible::Block => println!("User Not allowed to run command"), + Permissible::Block => { + println!("User Not allowed to run command"); + // None::<(BotAction,PrivmsgMessage)> + None::<&PrivmsgMessage> + //None + //Some(String::from("Hello")) + }, // _ => (), - } + }; // c.execute(self.chat.clone(), msg.clone()).await; + } + None::<&PrivmsgMessage> // [ ] Command not confirmed? }, - crate::core::botmodules::BotAction::L(l) => l.execute(self.botmgrs.clone(), msg.clone()).await, + // crate::core::botmodules::BotAction::L(l) => l.execute(self.botmgrs.clone(), msg.clone()).await, + //crate::core::botmodules::BotAction::L(l) => l.execute(self.botmgrs, msg.clone()).await, - _ => (), + _ => None::<&PrivmsgMessage> , // -- [ ] If not any known botaction + }; + + // b = BotAction either found or not + 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 + */ + } + None => (), } + + + + } }; + + // // [ ] There should be a BotCommand Listener to check for prefixes ran println!("End of Separate Listener Main prvmsg");