Chat say functionality #41

Merged
modulatingforce merged 14 commits from chat-say into main 2024-03-24 00:00:48 -04:00
Showing only changes of commit ff6046bb1f - Show all commits

View file

@ -171,6 +171,7 @@ impl BotInstance {
);
}
ServerMessage::Privmsg(msg) => {
botlog::debug(
format!(
"[Twitch Chat > {}] > {}: {}",
@ -181,6 +182,17 @@ impl BotInstance {
Some(&msg),
);
botlog::trace(
format!(
"[TRACE][Twitch Chat > {}] > {}: {:?}",
msg.channel_login, msg.sender.name, msg
)
.as_str(),
Some("BotInstance > runner()".to_string()),
Some(&msg),
);
BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await;
}
ServerMessage::Whisper(msg) => {
@ -243,6 +255,59 @@ impl BotInstance {
Some(msg),
);
// /*
// [ ] Here, msg is taken, and message_text is split so we can pull the first argument
// */
// let inpt = msg
// .message_text
// .split(' ')
// .next()
// .expect("ERROR during BotCommand");
/*
[ ] What we should do instead is :
1. Check if the message is related to a Reply (so we know how many arguments we should skip)
2. If a reply, skip the first argument
*/
let mut msgiter= msg
.message_text
.split(' ');
let arg1 = msgiter.next();
let arg2 = msgiter.next();
let reply = if let Some(replyidout) = msg.source.tags.0.get("reply-thread-parent-msg-id") {
if let Some(replyid) = replyidout {
// println!("Detected Reply : {}",replyid);
Some(replyid)
} else { None }
} else { None }
;
// let inpt = match reply {
// None => arg1, // Regular message, use the first arg as the command
// Some(_) => arg2, // A reply message, use the 2nd arg as the command
// };
let inpt = match reply {
None => { // Regular message, use the first arg as the command
match arg1 {
None => return, // return if no argument found
Some(a) => a,
}
},
Some(_) => {
match arg2 { // A reply message, use the 2nd arg as the command
None => return, // return if no argument found
Some(a) => a,
}
},
};
for acts in (*actsdblock).values() {
for a in acts {
match a {
@ -263,11 +328,31 @@ impl BotInstance {
Some(msg),
);
let inpt = msg
.message_text
.split(' ')
.next()
.expect("ERROR during BotCommand");
// /*
// [ ] Here, msg is taken, and message_text is split so we can pull the first argument
// */
// let inpt = msg
// .message_text
// .split(' ')
// .next()
// .expect("ERROR during BotCommand");
// /*
// [ ] What we should do instead is :
// 1. Check if the message is related to a Reply (so we know how many arguments we should skip)
// 2. If a reply, skip the first argument
// */
// if let Some(rslt) = msg.source.tags.0.get("reply-thread-parent-msg-id") {
// if let Some(rslt) = rslt {
// println!("Detected Reply : {}",rslt);
// }
// }
// [x] Check if a bot command based on ...
// [x] prefix + command