experiments module

This commit is contained in:
ModulatingForce 2024-03-23 19:20:43 -04:00
parent 7e59b8b251
commit 0e12cd1bff

View file

@ -65,31 +65,50 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
<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
let argrslt =
if let Some((_,str1)) = msg.message_text.split_once(" ") {
if reply_parent.is_none() {
if let Some((channelstr,msgstr)) = str1.split_once(" ") {
// println!("{}",cmdstr);
// println!("{}",channelstr);
// 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 };
match argrslt {
Some((trgchnl,outmsg)) => {
let newoutmsg = format!("{} (from #{}) says : {}",
msg.sender.name,msg.channel_login, outmsg);
let bot = Arc::clone(&bot);
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) {
// in the case where the provided channel isn't something we're known to be connected to
// botlog::warn(
// &format!("A message attempted to send for a Non-Joined Channel : {}",channel_login.clone()),
// Some("Chat > send_botmsg".to_string()),
// None,
// );
botlog::warn(
&format!("A message attempted to send for a Non-Joined Channel : {}",trgchnl.to_string().clone()),
Some("Chat > send_botmsg".to_string()),
None,
);
// return ;
botlock
.botmgrs
.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;
}
// 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
botlock
.botmgrs