Working BotCommand ExecBodies
This commit is contained in:
parent
3585c1ec9b
commit
b53047e7cf
3 changed files with 72 additions and 85 deletions
src/core
|
@ -56,7 +56,7 @@ impl Chat {
|
|||
pub async fn say_in_reply_to(&mut self, msg:& PrivmsgMessage , mut outmsg:String) -> () {
|
||||
/*
|
||||
formats message before sending to TwitchIRC
|
||||
|
||||
|
||||
- [x] Custom String Formatting (e.g., adding random black spaces)
|
||||
- [x] Ratelimiter Handling
|
||||
- [ ] Checkf if BotActions is Enabled & Caller is Allowed to Run
|
||||
|
@ -269,16 +269,40 @@ impl BotInstance
|
|||
|
||||
async fn listener_main_prvmsg(&mut self,msg:PrivmsgMessage) -> () {
|
||||
|
||||
println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
// println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
// // [ ] Need to run through all Listener Bodies for Enabled Modules for the context of the message (e.g., ModStatus is Enabled in the context for the channel)
|
||||
|
||||
for (_m,acts) in &self.botmodules.botactions {
|
||||
for a in acts {
|
||||
// if let crate::core::botmodules::BotAction::L(lsnr) = a {
|
||||
// lsnr.execute(self.chat.clone(),msg.clone()).await;
|
||||
// }
|
||||
a.execute(self.chat.clone(), msg.clone()).await;
|
||||
|
||||
match a {
|
||||
|
||||
crate::core::botmodules::BotAction::C(c) => {
|
||||
/*
|
||||
BotCommand handling -
|
||||
- Checks if the input message is a prefix with command name or alias
|
||||
*/
|
||||
|
||||
let inpt = msg.message_text.split("\n").next().expect("ERROR during BotCommand");
|
||||
|
||||
// [x] Check if a bot command based on ...
|
||||
// [x] prefix + command
|
||||
if inpt == self.prefix.to_string() + c.command.as_str() {
|
||||
c.execute(self.chat.clone(), msg.clone()).await;
|
||||
}
|
||||
|
||||
// [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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
crate::core::botmodules::BotAction::L(l) => l.execute(self.chat.clone(), msg.clone()).await,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue