adj sayinreply to use channel & msgid
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
ModulatingForce 2024-04-03 18:33:15 -04:00
parent 7199703766
commit 6867cc7af8
3 changed files with 51 additions and 21 deletions

View file

@ -41,7 +41,8 @@ pub enum BotMsgType {
// SayInReplyTo(&'a PrivmsgMessage,String),
// SayInReplyTo(Arc<Box<dyn ReplyToMessage>>,String),
// SayInReplyTo(&'a dyn ReplyToMessage,String), // [ ] 04.03 - Having issues defining it this way?
SayInReplyTo((String,String),String), // ( Destination Channel , Message ID to reply to ) , OutMessage // https://docs.rs/twitch-irc/latest/twitch_irc/client/struct.TwitchIRCClient.html#method.say_in_reply_to
// SayInReplyTo((String,String),String), // ( Destination Channel , Message ID to reply to ) , OutMessage // https://docs.rs/twitch-irc/latest/twitch_irc/client/struct.TwitchIRCClient.html#method.say_in_reply_to
SayInReplyTo(Channel,String,String), // ( Destination Channel , Message ID to reply to , OutMessage ) // https://docs.rs/twitch-irc/latest/twitch_irc/client/struct.TwitchIRCClient.html#method.say_in_reply_to
Say(String,String),
Notif(String), // For Bot Sent Notifications
}
@ -88,10 +89,11 @@ impl Chat {
*/
let (channel_login,mut outmsg) = match msginput.clone() {
BotMsgType::SayInReplyTo(msg, outmsg) => {
// BotMsgType::SayInReplyTo(msg, outmsg) => {
BotMsgType::SayInReplyTo(chnl, _, outmsg) => {
// (msg.channel_login.clone(),outmsg)
// (msg.clone().channel_login().to_string(),outmsg)
(msg.0, // Desintation Channel
(chnl.0.to_lowercase(), // Desintation Channel
outmsg)
},
BotMsgType::Say(a,b ) => {
@ -123,13 +125,16 @@ impl Chat {
).await;
if !params.bot.read().await.bot_channels.contains(&Channel(channel_login.clone())) {
dbg!("ISSUE : NONJOINED CHANNEL",&params.bot.read().await.bot_channels,Channel(channel_login.clone()));
botlog::warn(
&format!("A message attempted to send for a Non-Joined Channel : {}",channel_login.clone()),
Some("Chat > send_botmsg".to_string()),
None,
);
if let BotMsgType::SayInReplyTo(_prvmsg,_outmsg) = msginput {
// if let BotMsgType::SayInReplyTo(_prvmsg,_outmsg) = msginput {
if let BotMsgType::SayInReplyTo(_chnl,_msgid, _outmsg) = msginput {
self.send_botmsg(BotMsgType::Notif(
"uuh Bot can't send to a channel it isn't joined".to_string(),
@ -177,7 +182,8 @@ impl Chat {
match msginput {
BotMsgType::Notif(_) => (), // Do nothing with Notif > We'll validate the user later to handle
BotMsgType::SayInReplyTo(_, _) | BotMsgType::Say(_,_) => {
// BotMsgType::SayInReplyTo(_, _) | BotMsgType::Say(_,_) => {
BotMsgType::SayInReplyTo(_, _, _) | BotMsgType::Say(_,_) => {
botlog::trace(
"BEFORE potential Async recursion",
@ -276,7 +282,8 @@ impl Chat {
return;
}
},
BotMsgType::SayInReplyTo(_,_ ) | BotMsgType::Say(_,_) => {
// BotMsgType::SayInReplyTo(_,_ ) | BotMsgType::Say(_,_) => {
BotMsgType::SayInReplyTo(_,_,_ ) | BotMsgType::Say(_,_) => {
// If the BotMsg a Say/SayInReplyTo (from Developer or Chatter) , and the Sender does not have Specific Roles in the Source Channel Sent
self.send_botmsg(BotMsgType::Notif(
@ -349,18 +356,25 @@ impl Chat {
}
match msginput.clone() {
BotMsgType::SayInReplyTo(msg, _) => {
// BotMsgType::SayInReplyTo(msg, _) => {
// BotMsgType::SayInReplyTo(msg, _, _) => {
BotMsgType::SayInReplyTo(chnl,msgid, _) => {
// dbg!(msg.clone().channel_login(),msg.message_id(),outmsg.clone());
dbg!(chnl.clone(),msgid.clone(),outmsg.clone());
dbg!(msg.clone().channel_login(),msg.message_id(),outmsg.clone());
self.client.say_in_reply_to(&(
msg.clone().channel_login().to_string(),
msg.message_id().to_string()),
chnl.0,
msgid),
outmsg).await.unwrap();
},
BotMsgType::Say(a, _) => {
self.client.say(a, outmsg).await.unwrap();
}
BotMsgType::Notif(outmsg) => {
// dbg!(chnl.clone(),msgid.clone(),outmsg.clone());
dbg!(params.msg.channel_login(),params.msg.message_id());
self.client.say_in_reply_to(&params.msg, outmsg).await.unwrap();
}
}
@ -372,7 +386,8 @@ impl Chat {
channel_login.clone(), "rate limit counter increase", contextratelimiter
);
if let BotMsgType::SayInReplyTo(_,_ ) = msginput {
// if let BotMsgType::SayInReplyTo(_,_ ) = msginput {
if let BotMsgType::SayInReplyTo(_,_,_ ) = msginput {
botlog::trace(
logstr.as_str(),
Some("Chat > send_botmsg".to_string()),
@ -408,7 +423,14 @@ impl Chat {
// #[async_recursion]
// pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String , params : ExecBodyParams) {
// pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String , params : ExecBodyParams) {
pub async fn say_in_reply_to(&self, msg: &impl ReplyToMessage, outmsg: String , params : ExecBodyParams) {
// pub async fn say_in_reply_to(&self, msg: &impl ReplyToMessage, outmsg: String , params : ExecBodyParams) {
pub async fn say_in_reply_to(
&self,
destination_channel : Channel ,
reply_message_id : String ,
outmsg: String ,
params : ExecBodyParams)
{
// let params_clone = params.clone();
@ -462,8 +484,8 @@ impl Chat {
self.send_botmsg(BotMsgType::SayInReplyTo(
(msg.channel_login().to_string(),
msg.message_id().to_string()),
destination_channel,
reply_message_id,
outmsg) , params).await;
}

View file

@ -15,6 +15,7 @@ const OF_CMD_CHANNEL:Channel = Channel(String::new());
use rand::Rng;
use twitch_irc::message::ReplyToMessage;
use std::sync::Arc;
use crate::core::bot_actions::ExecBodyParams;
@ -140,7 +141,8 @@ async fn rp(params : ExecBodyParams)
.chat
.say_in_reply_to(
//using the tuple as param to the message being replied
&answear,
Channel(answear.0),
answear.1,
String::from("hey there"),
params.clone()
).await;
@ -188,7 +190,8 @@ async fn good_girl(params : ExecBodyParams) {
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
Channel(params.clone().msg.channel_login().to_string()),
params.clone().msg.message_id().to_string(),
String::from("GoodGirl xdd "),
params.clone()
).await;
@ -228,7 +231,8 @@ async fn babygirl(params : ExecBodyParams) {
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
Channel(params.clone().msg.channel_login().to_string()),
params.clone().msg.message_id().to_string(),
String::from("16:13 notohh: cafdk"),
params.clone()
).await;
@ -240,7 +244,8 @@ async fn babygirl(params : ExecBodyParams) {
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
Channel(params.clone().msg.channel_login().to_string()),
params.clone().msg.message_id().to_string(),
String::from("16:13 notohh: have fun eating princess"),
params.clone()
).await;
@ -252,7 +257,8 @@ async fn babygirl(params : ExecBodyParams) {
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
Channel(params.clone().msg.channel_login().to_string()),
params.clone().msg.message_id().to_string(),
String::from("16:13 notohh: baby girl"),
params.clone()
).await;

View file

@ -17,6 +17,7 @@ const OF_CMD_CHANNEL:Channel = Channel(String::new());
use std::sync::Arc;
use chrono::{TimeZone,Local};
use twitch_irc::message::ReplyToMessage;
use crate::core::bot_actions::ExecBodyParams;
@ -180,7 +181,8 @@ async fn sayout(params : ExecBodyParams) {
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
Channel(params.clone().msg.channel_login().to_string()),
params.clone().msg.message_id().to_string(),
String::from("Invalid arguments"),
params.clone()
).await;