(init) say require parent module
This commit is contained in:
parent
7e5e43fec3
commit
ee0b9ee196
6 changed files with 344 additions and 81 deletions
|
@ -412,7 +412,10 @@ impl BotInstance {
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
let outstr =
|
let outstr =
|
||||||
format!("sadg Module is disabled : {:?}",a);
|
format!("sadg Module is disabled : {:?}",a);
|
||||||
botlock.botmgrs.chat.say_in_reply_to(msg, outstr).await;
|
botlock.botmgrs.chat.say_in_reply_to(
|
||||||
|
msg,
|
||||||
|
outstr,
|
||||||
|
c.module.clone()).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -451,7 +454,11 @@ impl BotInstance {
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
let outstr =
|
let outstr =
|
||||||
"o7 a Mod. I kneel to serve! pepeKneel ".to_string();
|
"o7 a Mod. I kneel to serve! pepeKneel ".to_string();
|
||||||
botlock.botmgrs.chat.say_in_reply_to(msg, outstr).await;
|
botlock.botmgrs.chat.say_in_reply_to(
|
||||||
|
msg,
|
||||||
|
outstr,
|
||||||
|
c.module.clone(),
|
||||||
|
).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,22 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Get parent module
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// [x] Unwraps arguments from message
|
// [x] Unwraps arguments from message
|
||||||
|
@ -173,11 +189,16 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Only call Say if there is a parent module passed
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, outmsg.to_string())
|
.say_in_reply_to(¶ms.msg, outmsg.to_string() , parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -216,12 +237,20 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
ChangeResult::Success(a) => format!("YAAY Success : {}",a),
|
ChangeResult::Success(a) => format!("YAAY Success : {}",a),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Only call Say if there is a parent module passed
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, outmsg.to_string())
|
.say_in_reply_to(¶ms.msg, outmsg.to_string(),parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,6 +311,20 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
3c. , and is -f (forced) , return a Success
|
3c. , and is -f (forced) , return a Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
[x] Get the parent module
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// [x] Unwraps arguments from message
|
// [x] Unwraps arguments from message
|
||||||
|
|
||||||
|
@ -351,12 +394,29 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
// let actlock = params_clone.read().await;
|
||||||
|
// let act = &(*actlock);
|
||||||
|
// let parent_module = match act {
|
||||||
|
// BotAction::C(c) => Some(&(*c).module),
|
||||||
|
// BotAction::L(l) => Some(&(*l).module),
|
||||||
|
// _ => None,
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Only call Say if there is a parent module passed
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, outmsg.to_string())
|
.say_in_reply_to(¶ms.msg, outmsg.to_string(),parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -397,12 +457,36 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
ChangeResult::Success(a) => format!("YAAY Success : {}",a),
|
ChangeResult::Success(a) => format!("YAAY Success : {}",a),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// let actlock = params.parent_act.read().await;
|
||||||
|
// let act = *actlock;
|
||||||
|
// let parent_module = match act {
|
||||||
|
// BotAction::C(c) => Some(c.module),
|
||||||
|
// BotAction::L(l) => Some(l.module),
|
||||||
|
// _ => None,
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
// let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
// let actlock = params_clone.read().await;
|
||||||
|
// let act = &(*actlock);
|
||||||
|
// let parent_module = match act {
|
||||||
|
// BotAction::C(c) => Some(&(*c).module),
|
||||||
|
// BotAction::L(l) => Some(&(*l).module),
|
||||||
|
// _ => None,
|
||||||
|
// };
|
||||||
|
|
||||||
|
// Only call Say if there is a parent module passed
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, outmsg.to_string())
|
.say_in_reply_to(¶ms.msg, outmsg.to_string(),parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -413,13 +497,8 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
// pub enum BotModule {
|
|
||||||
// BotModule(String),
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub struct BotModule(pub String);
|
pub struct BotModule(pub String);
|
||||||
|
|
||||||
|
|
||||||
impl PartialEq for BotModule {
|
impl PartialEq for BotModule {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
let BotModule(name1) = self.clone();
|
let BotModule(name1) = self.clone();
|
||||||
|
|
|
@ -21,6 +21,8 @@ use crate::core::botlog;
|
||||||
|
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
|
use super::botmodules::BotModule;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Chat {
|
pub struct Chat {
|
||||||
pub ratelimiters: Arc<Mutex<HashMap<Channel, RateLimiter>>>, // used to limit messages sent per channel
|
pub ratelimiters: Arc<Mutex<HashMap<Channel, RateLimiter>>>, // used to limit messages sent per channel
|
||||||
|
@ -54,7 +56,8 @@ impl Chat {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async fn send_botmsg(&self, msginput: BotMsgType<'_>) {
|
// async fn send_botmsg(&self, msginput: BotMsgType<'_>) {
|
||||||
|
async fn send_botmsg(&self, msginput: BotMsgType<'_>, _ : BotModule) {
|
||||||
/*
|
/*
|
||||||
formats message before sending to TwitchIRC
|
formats message before sending to TwitchIRC
|
||||||
|
|
||||||
|
@ -159,16 +162,18 @@ impl Chat {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String) {
|
// pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String) {
|
||||||
|
pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String , parent_module : BotModule) {
|
||||||
|
|
||||||
self.send_botmsg(BotMsgType::SayInReplyTo(msg, outmsg)).await;
|
self.send_botmsg(BotMsgType::SayInReplyTo(msg, outmsg) , parent_module).await;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn say(&self, channel_login: String, message: String) {
|
// pub async fn say(&self, channel_login: String, message: String) {
|
||||||
|
pub async fn say(&self, channel_login: String, message: String , parent_module : BotModule) {
|
||||||
// more info https://docs.rs/twitch-irc/latest/twitch_irc/client/struct.TwitchIRCClient.html#method.say
|
// more info https://docs.rs/twitch-irc/latest/twitch_irc/client/struct.TwitchIRCClient.html#method.say
|
||||||
|
|
||||||
self.send_botmsg(BotMsgType::Say(channel_login.to_lowercase(), message)).await;
|
self.send_botmsg(BotMsgType::Say(channel_login.to_lowercase(), message), parent_module).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn _me(&self, _: String, _: String) {
|
async fn _me(&self, _: String, _: String) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::core::bot_actions::BotAR;
|
||||||
use crate::core::bot_actions::ExecBodyParams;
|
use crate::core::bot_actions::ExecBodyParams;
|
||||||
use crate::core::botinstance::{Channel,ChangeResult};
|
use crate::core::botinstance::{Channel,ChangeResult};
|
||||||
use crate::core::botlog;
|
use crate::core::botlog;
|
||||||
|
use crate::core::botmodules::BotAction;
|
||||||
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
|
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
|
||||||
|
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
|
@ -106,6 +107,21 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
[x] Get the parent module
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// println!("{}",params.msg.message_text);
|
// println!("{}",params.msg.message_text);
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
format!("Twich Message > {}", params.msg.message_text).as_str(),
|
format!("Twich Message > {}", params.msg.message_text).as_str(),
|
||||||
|
@ -214,12 +230,21 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Only call Say if there is a parent module passed
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, outmsg.to_string())
|
.say_in_reply_to(
|
||||||
|
¶ms.msg,
|
||||||
|
outmsg.to_string(),
|
||||||
|
parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
// &format!("End of cmd_promote()"),
|
// &format!("End of cmd_promote()"),
|
||||||
"End of cmd_promote()",
|
"End of cmd_promote()",
|
||||||
|
@ -281,6 +306,22 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
[x] Get the parent module
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// [x] Unwraps arguments from message
|
// [x] Unwraps arguments from message
|
||||||
|
|
||||||
let (arg1, _arg2) = {
|
let (arg1, _arg2) = {
|
||||||
|
@ -414,11 +455,23 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Only call Say if there is a parent module passed
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, outmsg.to_string())
|
.say_in_reply_to(
|
||||||
|
¶ms.msg,
|
||||||
|
outmsg.to_string(),
|
||||||
|
parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let tempcomm = BotCommand {
|
let tempcomm = BotCommand {
|
||||||
|
@ -455,6 +508,20 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
[x] Get the parent module
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
let mut argv = params.msg.message_text.split(' ');
|
let mut argv = params.msg.message_text.split(' ');
|
||||||
|
|
||||||
argv.next(); // Skip the command name
|
argv.next(); // Skip the command name
|
||||||
|
@ -566,7 +633,16 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
|
|
||||||
botlock.botmgrs.chat.say_in_reply_to(¶ms.msg, outmsg).await;
|
if parent_module.is_some() {
|
||||||
|
|
||||||
|
botlock.botmgrs.chat.say_in_reply_to(
|
||||||
|
¶ms.msg,
|
||||||
|
outmsg,
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// [ ] NOTE : After the above, I should receive only the roles in the context of the current channel I received this ideally and maybe BotAdmin ; not outside
|
// [ ] NOTE : After the above, I should receive only the roles in the context of the current channel I received this ideally and maybe BotAdmin ; not outside
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ use crate::core::botlog;
|
||||||
|
|
||||||
use crate::core::bot_actions::actions_util;
|
use crate::core::bot_actions::actions_util;
|
||||||
use crate::core::bot_actions::BotAR;
|
use crate::core::bot_actions::BotAR;
|
||||||
|
use crate::core::botmodules::BotAction;
|
||||||
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
|
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, Listener, ModulesManager};
|
||||||
|
|
||||||
use crate::core::identity::UserRole::*;
|
use crate::core::identity::UserRole::*;
|
||||||
|
@ -113,6 +114,19 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
// async fn good_girl(bot: BotAR, msg: PrivmsgMessage) {
|
// async fn good_girl(bot: BotAR, msg: PrivmsgMessage) {
|
||||||
async fn good_girl(params : ExecBodyParams) {
|
async fn good_girl(params : ExecBodyParams) {
|
||||||
|
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// [ ] Uses gen_ratio() to output bool based on a ratio probability .
|
// [ ] Uses gen_ratio() to output bool based on a ratio probability .
|
||||||
// - For example gen_ratio(2,3) is 2 out of 3 or 0.67% (numerator,denomitator)
|
// - For example gen_ratio(2,3) is 2 out of 3 or 0.67% (numerator,denomitator)
|
||||||
// - More Info : https://rust-random.github.io/rand/rand/trait.Rng.html#method.gen_ratio
|
// - More Info : https://rust-random.github.io/rand/rand/trait.Rng.html#method.gen_ratio
|
||||||
|
@ -140,12 +154,21 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
|
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
|
|
||||||
|
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, String::from("GoodGirl xdd "))
|
.say_in_reply_to(
|
||||||
.await;
|
¶ms.msg,
|
||||||
|
String::from("GoodGirl xdd "),
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,6 +186,22 @@ async fn testy(params : ExecBodyParams) {
|
||||||
|
|
||||||
// async fn babygirl(bot: BotAR, msg: PrivmsgMessage) {
|
// async fn babygirl(bot: BotAR, msg: PrivmsgMessage) {
|
||||||
async fn babygirl(params : ExecBodyParams) {
|
async fn babygirl(params : ExecBodyParams) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
[x] Get the parent module
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
println!("babygirl triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
|
println!("babygirl triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
|
||||||
botlog::debug(
|
botlog::debug(
|
||||||
"babygirl triggered!",
|
"babygirl triggered!",
|
||||||
|
@ -175,12 +214,17 @@ async fn babygirl(params : ExecBodyParams) {
|
||||||
|
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
|
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, String::from("16:13 notohh: cafdk"))
|
.say_in_reply_to(
|
||||||
.await;
|
¶ms.msg,
|
||||||
|
String::from("16:13 notohh: cafdk"),
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
|
||||||
sleep(Duration::from_secs_f64(0.5)).await;
|
sleep(Duration::from_secs_f64(0.5)).await;
|
||||||
|
@ -188,8 +232,11 @@ async fn babygirl(params : ExecBodyParams) {
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, String::from("16:13 notohh: have fun eating princess"))
|
.say_in_reply_to(
|
||||||
.await;
|
¶ms.msg,
|
||||||
|
String::from("16:13 notohh: have fun eating princess"),
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
|
||||||
sleep(Duration::from_secs_f64(2.0)).await;
|
sleep(Duration::from_secs_f64(2.0)).await;
|
||||||
|
@ -197,8 +244,13 @@ async fn babygirl(params : ExecBodyParams) {
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, String::from("16:13 notohh: baby girl"))
|
.say_in_reply_to(
|
||||||
.await;
|
¶ms.msg,
|
||||||
|
String::from("16:13 notohh: baby girl"),
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ use crate::core::bot_actions::ExecBodyParams;
|
||||||
use crate::core::botinstance::Channel;
|
use crate::core::botinstance::Channel;
|
||||||
// use ChType::Channel;
|
// use ChType::Channel;
|
||||||
use crate::core::botlog;
|
use crate::core::botlog;
|
||||||
|
use crate::core::botmodules::BotAction;
|
||||||
|
|
||||||
use casual_logger::Log;
|
use casual_logger::Log;
|
||||||
|
|
||||||
|
@ -71,6 +72,24 @@ async fn sayout(params : ExecBodyParams) {
|
||||||
<target channel> <message>
|
<target channel> <message>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
[x] Get the parent module
|
||||||
|
*/
|
||||||
|
|
||||||
|
let params_clone = Arc::clone(¶ms.parent_act);
|
||||||
|
let actlock = params_clone.read().await;
|
||||||
|
let act = &(*actlock);
|
||||||
|
let parent_module = match act {
|
||||||
|
BotAction::C(c) => Some(&(*c).module),
|
||||||
|
BotAction::L(l) => Some(&(*l).module),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let reply_parent = if let Some(Some(reply)) = params.msg.source.tags.0.get("reply-parent-msg-body") {
|
let reply_parent = if let Some(Some(reply)) = params.msg.source.tags.0.get("reply-parent-msg-body") {
|
||||||
Some(reply)
|
Some(reply)
|
||||||
} else { None }
|
} else { None }
|
||||||
|
@ -141,11 +160,19 @@ async fn sayout(params : ExecBodyParams) {
|
||||||
);
|
);
|
||||||
// return ;
|
// return ;
|
||||||
|
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, format!("Not a Joined Channel : {}",trgchnl))
|
.say_in_reply_to(
|
||||||
.await;
|
¶ms.msg,
|
||||||
|
format!("Not a Joined Channel : {}",trgchnl),
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -195,13 +222,22 @@ async fn sayout(params : ExecBodyParams) {
|
||||||
outmsg)
|
outmsg)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
|
|
||||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say(trgchnl.to_string(), newoutmsg.to_string())
|
.say(
|
||||||
|
trgchnl.to_string(),
|
||||||
|
newoutmsg.to_string(),
|
||||||
|
parent_module.unwrap().clone())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -216,12 +252,20 @@ async fn sayout(params : ExecBodyParams) {
|
||||||
|
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
|
|
||||||
|
|
||||||
|
if parent_module.is_some() {
|
||||||
|
|
||||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(¶ms.msg, String::from("Invalid arguments"))
|
.say_in_reply_to(
|
||||||
.await;
|
¶ms.msg,
|
||||||
|
String::from("Invalid arguments"),
|
||||||
|
parent_module.unwrap().clone()
|
||||||
|
).await;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue