experiments module
This commit is contained in:
parent
7e59b8b251
commit
0e12cd1bff
1 changed files with 80 additions and 18 deletions
|
@ -65,31 +65,50 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
||||||
<target channel> <message>
|
<target channel> <message>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
let reply_parent = if let Some(replyout) = msg.source.tags.0.get("reply-parent-msg-body") {
|
||||||
|
if let Some(replymsg) = replyout {
|
||||||
|
// println!("Detected Reply : {}",replyid);
|
||||||
|
Some(replymsg)
|
||||||
|
} else { None }
|
||||||
|
} else { None }
|
||||||
|
;
|
||||||
|
|
||||||
|
let reply_parent_usr = if let Some(replyout) = msg.source.tags.0.get("reply-thread-parent-user-login") {
|
||||||
|
if let Some(replymsgusr) = replyout {
|
||||||
|
// println!("Detected Reply : {}",replyid);
|
||||||
|
Some(replymsgusr)
|
||||||
|
} else { None }
|
||||||
|
} else { None }
|
||||||
|
;
|
||||||
|
|
||||||
// [x] Unwraps arguments from message
|
// [x] Unwraps arguments from message
|
||||||
|
|
||||||
let argrslt =
|
let argrslt =
|
||||||
if let Some((_,str1)) = msg.message_text.split_once(" ") {
|
if let Some((_,str1)) = msg.message_text.split_once(" ") {
|
||||||
if let Some((channelstr,msgstr)) = str1.split_once(" ") {
|
if reply_parent.is_none() {
|
||||||
// println!("{}",cmdstr);
|
if let Some((channelstr,msgstr)) = str1.split_once(" ") {
|
||||||
// println!("{}",channelstr);
|
Some((channelstr,msgstr))
|
||||||
// println!("{}",msgstr);
|
}
|
||||||
Some((channelstr,msgstr))
|
else { None }
|
||||||
|
} else {
|
||||||
|
if let Some((_,str2)) = str1.split_once(" ") {
|
||||||
|
if let Some((channelstr,msgstr)) = str2.split_once(" ") {
|
||||||
|
Some((channelstr,msgstr))
|
||||||
|
}
|
||||||
|
else { None }
|
||||||
|
}
|
||||||
|
else { None }
|
||||||
}
|
}
|
||||||
else { None }
|
|
||||||
}
|
}
|
||||||
else { None };
|
else { None };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
match argrslt {
|
match argrslt {
|
||||||
Some((trgchnl,outmsg)) => {
|
Some((trgchnl,outmsg)) => {
|
||||||
|
|
||||||
let newoutmsg = format!("{} (from #{}) says : {}",
|
|
||||||
msg.sender.name,msg.channel_login, outmsg);
|
|
||||||
|
|
||||||
|
|
||||||
let bot = Arc::clone(&bot);
|
let bot = Arc::clone(&bot);
|
||||||
|
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
|
@ -98,23 +117,66 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
||||||
|
|
||||||
if botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await == (false,false) {
|
if botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await == (false,false) {
|
||||||
// in the case where the provided channel isn't something we're known to be connected to
|
// in the case where the provided channel isn't something we're known to be connected to
|
||||||
// botlog::warn(
|
botlog::warn(
|
||||||
// &format!("A message attempted to send for a Non-Joined Channel : {}",channel_login.clone()),
|
&format!("A message attempted to send for a Non-Joined Channel : {}",trgchnl.to_string().clone()),
|
||||||
// Some("Chat > send_botmsg".to_string()),
|
Some("Chat > send_botmsg".to_string()),
|
||||||
// None,
|
None,
|
||||||
// );
|
);
|
||||||
// return ;
|
// return ;
|
||||||
|
|
||||||
botlock
|
botlock
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(&msg, format!("Cannot join channel : {}",trgchnl.to_string()))
|
.say_in_reply_to(&msg, format!("Not a Joined Channel : {}",trgchnl.to_string()))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if let Some((arg1,arg1other)) = msg.message_text.split_once(' ') {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. If a Reply ,
|
||||||
|
[ ] Get Parent Content message - reply_parent
|
||||||
|
[ ] Get Parent Chatter - reply_parent_usr
|
||||||
|
[ ] Get Parent Channel - msg.channel_login
|
||||||
|
-> Share this first then
|
||||||
|
[ ] Get Reply Message (that triggered bot command) - msgstr
|
||||||
|
[ ] Get Reply Sender - msg.sender.name
|
||||||
|
[ ] Get Target Channel - trgchnl
|
||||||
|
|
||||||
|
2. If not a reply
|
||||||
|
[ ] Get Reply Message (that triggered bot command) - msgstr
|
||||||
|
[ ] Get Reply Sender - msg.sender.name
|
||||||
|
[ ] Get Target Channel - trgchnl
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if let Some(srcmsg) = reply_parent {
|
||||||
|
|
||||||
|
let newoutmsg = format!("{} from #{} Shared >> {} : {}",
|
||||||
|
msg.sender.name,msg.channel_login, reply_parent_usr.unwrap(),srcmsg);
|
||||||
|
|
||||||
|
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||||
|
botlock
|
||||||
|
.botmgrs
|
||||||
|
.chat
|
||||||
|
.say(trgchnl.to_string(), newoutmsg.to_string())
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let newoutmsg = format!("{} from #{} says : {}",
|
||||||
|
msg.sender.name,msg.channel_login, outmsg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|
Loading…
Reference in a new issue