(init) say require parent module
This commit is contained in:
parent
7e5e43fec3
commit
ee0b9ee196
6 changed files with 344 additions and 81 deletions
src/custom/experimental
|
@ -22,6 +22,7 @@ use crate::core::bot_actions::ExecBodyParams;
|
|||
use crate::core::botinstance::Channel;
|
||||
// use ChType::Channel;
|
||||
use crate::core::botlog;
|
||||
use crate::core::botmodules::BotAction;
|
||||
|
||||
use casual_logger::Log;
|
||||
|
||||
|
@ -71,6 +72,24 @@ async fn sayout(params : ExecBodyParams) {
|
|||
<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") {
|
||||
Some(reply)
|
||||
} else { None }
|
||||
|
@ -141,11 +160,19 @@ async fn sayout(params : ExecBodyParams) {
|
|||
);
|
||||
// return ;
|
||||
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(¶ms.msg, format!("Not a Joined Channel : {}",trgchnl))
|
||||
.await;
|
||||
if parent_module.is_some() {
|
||||
|
||||
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(
|
||||
¶ms.msg,
|
||||
format!("Not a Joined Channel : {}",trgchnl),
|
||||
parent_module.unwrap().clone()
|
||||
).await;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -195,12 +222,21 @@ async fn sayout(params : ExecBodyParams) {
|
|||
outmsg)
|
||||
};
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say(trgchnl.to_string(), newoutmsg.to_string())
|
||||
.await;
|
||||
|
||||
if parent_module.is_some() {
|
||||
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say(
|
||||
trgchnl.to_string(),
|
||||
newoutmsg.to_string(),
|
||||
parent_module.unwrap().clone())
|
||||
.await;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -216,12 +252,20 @@ async fn sayout(params : ExecBodyParams) {
|
|||
|
||||
let botlock = bot.read().await;
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
botlock
|
||||
|
||||
if parent_module.is_some() {
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(¶ms.msg, String::from("Invalid arguments"))
|
||||
.await;
|
||||
.say_in_reply_to(
|
||||
¶ms.msg,
|
||||
String::from("Invalid arguments"),
|
||||
parent_module.unwrap().clone()
|
||||
).await;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue