enh chat
This commit is contained in:
parent
8ed672fb3a
commit
e73bd75de9
10 changed files with 909 additions and 188 deletions
src/core
|
@ -43,12 +43,12 @@ use super::botmodules::StatusType;
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct BotManagers {
|
||||
pub identity: Arc<RwLock<IdentityManager>>,
|
||||
pub chat: Chat,
|
||||
pub chat: Arc<RwLock<Chat>>,
|
||||
}
|
||||
|
||||
impl BotManagers {
|
||||
pub fn init(
|
||||
ratelimiters: HashMap<Channel, RateLimiter>,
|
||||
ratelimiters: HashMap<Channel, Arc<RwLock<RateLimiter>>>,
|
||||
client: TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>,
|
||||
) -> BotManagers {
|
||||
BotManagers {
|
||||
|
@ -116,7 +116,7 @@ impl BotInstance {
|
|||
|
||||
client.join(chnl.to_owned()).unwrap();
|
||||
|
||||
let n = RateLimiter::new();
|
||||
let n = Arc::new(RwLock::new(RateLimiter::new()));
|
||||
ratelimiters.insert(Channel(String::from(chnl)), n);
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,18 @@ impl BotInstance {
|
|||
);
|
||||
Log::flush();
|
||||
|
||||
BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await;
|
||||
let botarc = Arc::clone(&bot);
|
||||
// let msgarc = Arc::new(RwLock::new(msg.clone()));
|
||||
|
||||
let msgtext = msg.message_text.clone();
|
||||
|
||||
dbg!("will spawn listener_main_prvmsg from runner",msgtext.clone());
|
||||
tokio::spawn( async move {
|
||||
// let msgarc_c = msgarc.clone();
|
||||
BotInstance::listener_main_prvmsg(botarc, &msg.clone()).await;
|
||||
});
|
||||
// BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await;
|
||||
dbg!("completed spawn listener_main_prvmsg from runner", msgtext);
|
||||
}
|
||||
ServerMessage::Whisper(msg) => {
|
||||
botlog::debug(
|
||||
|
@ -367,13 +378,13 @@ impl BotInstance {
|
|||
Channel(msg.channel_login.to_string())).await;
|
||||
|
||||
|
||||
if let StatusType::Disabled(a) = modstatus {
|
||||
if let StatusType::Disabled(statuslvl) = modstatus {
|
||||
|
||||
// [x] Should only respond if a BotAdmin , Mod , SupMod , BroadCaster
|
||||
// - Specifically it should respond only to those who may be able to enable the module
|
||||
|
||||
botlog::trace(
|
||||
&format!("Identified cmd is associated with Disabled Module : StatusLvl = {:?}", a),
|
||||
&format!("Identified cmd is associated with Disabled Module : StatusLvl = {:?}", statuslvl),
|
||||
Some("BotInstance > listener_main_prvmsg()".to_string()),
|
||||
Some(msg),
|
||||
);
|
||||
|
@ -397,9 +408,10 @@ impl BotInstance {
|
|||
);
|
||||
|
||||
// Only respond to those with th ebelow User Roles
|
||||
// [x] Need to add in Module as well
|
||||
|
||||
let outstr =
|
||||
format!("sadg Module is disabled : {:?}",a);
|
||||
format!("sadg Module is disabled : {:?} {:?}",c.module.clone(),statuslvl);
|
||||
|
||||
|
||||
let params = ExecBodyParams {
|
||||
|
@ -409,9 +421,11 @@ impl BotInstance {
|
|||
curr_act : Some(Arc::clone(&act_clone)),
|
||||
};
|
||||
|
||||
let params = Arc::new(RwLock::new(params));
|
||||
|
||||
// When sending a BotMsgTypeNotif, send_botmsg does Roles related validation as required
|
||||
|
||||
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
outstr
|
||||
),
|
||||
params,
|
||||
|
@ -468,7 +482,10 @@ impl BotInstance {
|
|||
|
||||
};
|
||||
|
||||
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
|
||||
let params = Arc::new(RwLock::new(params));
|
||||
|
||||
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
outstr.to_string()
|
||||
),
|
||||
params.clone(),
|
||||
|
@ -499,7 +516,10 @@ impl BotInstance {
|
|||
|
||||
};
|
||||
|
||||
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
|
||||
let params = Arc::new(RwLock::new(params));
|
||||
|
||||
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
|
||||
outstr.to_string()
|
||||
),
|
||||
params.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue