Listeners with exec_body can be added to ModulesManager
This commit is contained in:
parent
25b73c41cc
commit
88293377e8
3 changed files with 28 additions and 12 deletions
src/core
|
@ -27,11 +27,13 @@ use crate::core::ratelimiter;
|
|||
// println!("I was here");
|
||||
// }
|
||||
|
||||
// use crate::core::botmodules::BotAction
|
||||
|
||||
|
||||
use crate::core::botmodules;
|
||||
use crate::core::botmodules::ModulesManager;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||
pub enum ChType {
|
||||
Channel(String),
|
||||
}
|
||||
|
@ -59,6 +61,7 @@ pub use ModType::BotModule;
|
|||
// }
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Chat {
|
||||
pub ratelimiters : HashMap<ChType,RateLimiter>, // used to limit messages sent per channel
|
||||
pub client : TwitchIRCClient<TCPTransport<TLS>,StaticLoginCredentials>,
|
||||
|
@ -268,12 +271,16 @@ impl BotInstance
|
|||
|
||||
while let Some(message) = self.incoming_messages.recv().await {
|
||||
// Below can be used to debug if I want to capture all messages
|
||||
// println!("Received message: {:?}", message);
|
||||
//println!("Received message: {:?}", message);
|
||||
|
||||
match message {
|
||||
ServerMessage::Notice(msg) => {
|
||||
if let Some(chnl) = msg.channel_login {
|
||||
println!("NOTICE : (#{}) {}", chnl, msg.message_text);
|
||||
// if let Some(chnl) = msg.channel_login {
|
||||
// println!("NOTICE : (#{}) {}", chnl, msg.message_text);
|
||||
// }
|
||||
match msg.channel_login {
|
||||
Some(chnl) => println!("NOTICE : (#{}) {}", chnl, msg.message_text),
|
||||
None => println!("NOTICE : {}", msg.message_text),
|
||||
}
|
||||
}
|
||||
ServerMessage::Privmsg(msg) => {
|
||||
|
@ -282,7 +289,7 @@ impl BotInstance
|
|||
println!("Privmsg section");
|
||||
|
||||
// b.listener_main_prvmsg(&msg);
|
||||
self.listener_main_prvmsg(&msg).await;
|
||||
self.listener_main_prvmsg(msg).await;
|
||||
// - BotCommand listener should likely need to be called within the above
|
||||
|
||||
|
||||
|
@ -361,7 +368,7 @@ impl BotInstance
|
|||
// PRIVATE FUNCTIONS
|
||||
|
||||
|
||||
async fn listener_main_prvmsg(&mut self,msg:& PrivmsgMessage) -> () {
|
||||
async fn listener_main_prvmsg(&mut self,msg:PrivmsgMessage) -> () {
|
||||
|
||||
println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
|
@ -394,10 +401,17 @@ impl BotInstance
|
|||
// }
|
||||
|
||||
|
||||
self.chat.say_in_reply_to(msg,String::from("annytfLurk")).await;
|
||||
// self.chat.say_in_reply_to(msg,String::from("annytfLurk")).await;
|
||||
|
||||
// // [ ] 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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// // [ ] There should be a BotCommand Listener to check for prefixes ran
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue