enh chat.say_in_reply
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
This commit is contained in:
parent
57725ee840
commit
345cf97922
1 changed files with 34 additions and 13 deletions
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use twitch_irc::login::StaticLoginCredentials;
|
use twitch_irc::login::StaticLoginCredentials;
|
||||||
use twitch_irc::message::PrivmsgMessage;
|
use twitch_irc::message::{PrivmsgMessage, ReplyToMessage};
|
||||||
use twitch_irc::transport::tcp::{TCPTransport, TLS};
|
use twitch_irc::transport::tcp::{TCPTransport, TLS};
|
||||||
use twitch_irc::TwitchIRCClient;
|
use twitch_irc::TwitchIRCClient;
|
||||||
|
|
||||||
|
@ -34,9 +34,14 @@ pub struct Chat {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone,Debug)]
|
// #[derive(Clone,Debug)] // <-- [ ] 04.03 - was having issues using this
|
||||||
pub enum BotMsgType<'a> {
|
#[derive(Clone)]
|
||||||
SayInReplyTo(&'a PrivmsgMessage,String),
|
// pub enum BotMsgType<'a> {
|
||||||
|
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
|
||||||
Say(String,String),
|
Say(String,String),
|
||||||
Notif(String), // For Bot Sent Notifications
|
Notif(String), // For Bot Sent Notifications
|
||||||
}
|
}
|
||||||
|
@ -59,7 +64,8 @@ impl Chat {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
pub async fn send_botmsg(&self, msginput: BotMsgType<'async_recursion>, params : ExecBodyParams) {
|
// pub async fn send_botmsg(&self, msginput: BotMsgType<'async_recursion>, params : ExecBodyParams) {
|
||||||
|
pub async fn send_botmsg(&self, msginput: BotMsgType, params : ExecBodyParams) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,17 +78,21 @@ impl Chat {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* // [ ] 04.03 - Was having issues withh this
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
format!("send_bot_msg params : {:?}",msginput).as_str(),
|
format!("send_bot_msg params : {:?}",msginput).as_str(),
|
||||||
Some("chat.rs > send_botmsg ".to_string()),
|
Some("chat.rs > send_botmsg ".to_string()),
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
Log::flush();
|
Log::flush();
|
||||||
|
*/
|
||||||
|
|
||||||
let (channel_login,mut outmsg) = match msginput.clone() {
|
let (channel_login,mut outmsg) = match msginput.clone() {
|
||||||
BotMsgType::SayInReplyTo(msg, outmsg) => {
|
BotMsgType::SayInReplyTo(msg, outmsg) => {
|
||||||
(msg.channel_login.clone(),outmsg)
|
// (msg.channel_login.clone(),outmsg)
|
||||||
|
// (msg.clone().channel_login().to_string(),outmsg)
|
||||||
|
(msg.0, // Desintation Channel
|
||||||
|
outmsg)
|
||||||
},
|
},
|
||||||
BotMsgType::Say(a,b ) => {
|
BotMsgType::Say(a,b ) => {
|
||||||
(a.clone(),b.clone())
|
(a.clone(),b.clone())
|
||||||
|
@ -340,7 +350,12 @@ impl Chat {
|
||||||
|
|
||||||
match msginput.clone() {
|
match msginput.clone() {
|
||||||
BotMsgType::SayInReplyTo(msg, _) => {
|
BotMsgType::SayInReplyTo(msg, _) => {
|
||||||
self.client.say_in_reply_to(msg, outmsg).await.unwrap();
|
|
||||||
|
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()),
|
||||||
|
outmsg).await.unwrap();
|
||||||
},
|
},
|
||||||
BotMsgType::Say(a, _) => {
|
BotMsgType::Say(a, _) => {
|
||||||
self.client.say(a, outmsg).await.unwrap();
|
self.client.say(a, outmsg).await.unwrap();
|
||||||
|
@ -357,11 +372,12 @@ impl Chat {
|
||||||
channel_login.clone(), "rate limit counter increase", contextratelimiter
|
channel_login.clone(), "rate limit counter increase", contextratelimiter
|
||||||
);
|
);
|
||||||
|
|
||||||
if let BotMsgType::SayInReplyTo(msg,_ ) = msginput {
|
if let BotMsgType::SayInReplyTo(_,_ ) = msginput {
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
logstr.as_str(),
|
logstr.as_str(),
|
||||||
Some("Chat > send_botmsg".to_string()),
|
Some("Chat > send_botmsg".to_string()),
|
||||||
Some(msg),
|
// Some(msg),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
|
@ -390,7 +406,9 @@ impl Chat {
|
||||||
|
|
||||||
// pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String) {
|
// pub async fn say_in_reply_to(&self, msg: &PrivmsgMessage, outmsg: String) {
|
||||||
// #[async_recursion]
|
// #[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: &PrivmsgMessage, outmsg: String , params : ExecBodyParams) {
|
||||||
|
pub async fn say_in_reply_to(&self, msg: &impl ReplyToMessage, outmsg: String , params : ExecBodyParams) {
|
||||||
|
|
||||||
// let params_clone = params.clone();
|
// let params_clone = params.clone();
|
||||||
|
|
||||||
|
@ -443,7 +461,10 @@ impl Chat {
|
||||||
// Log::flush();
|
// Log::flush();
|
||||||
|
|
||||||
|
|
||||||
self.send_botmsg(BotMsgType::SayInReplyTo(msg, outmsg) , params).await;
|
self.send_botmsg(BotMsgType::SayInReplyTo(
|
||||||
|
(msg.channel_login().to_string(),
|
||||||
|
msg.message_id().to_string()),
|
||||||
|
outmsg) , params).await;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue