Chat say functionality #41

Merged
modulatingforce merged 14 commits from chat-say into main 2024-03-24 00:00:48 -04:00
3 changed files with 41 additions and 8 deletions
Showing only changes of commit 97d76ea088 - Show all commits

5
Cargo.lock generated
View file

@ -122,9 +122,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.34"
version = "0.4.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b"
checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a"
dependencies = [
"android-tzdata",
"iana-time-zone",
@ -196,6 +196,7 @@ version = "0.1.0"
dependencies = [
"async-trait",
"casual_logger",
"chrono",
"dotenv",
"futures",
"rand",

View file

@ -13,6 +13,7 @@ rand = { version = "0.8.5", features = [] }
futures = "0.3"
async-trait = "0.1.77"
casual_logger = "0.6.5"
chrono = "0.4.35"
[lib]
name = "bot_lib"

View file

@ -13,6 +13,8 @@
// use rand::Rng;
use std::sync::Arc;
use chrono::{TimeZone,Local};
use twitch_irc::message::PrivmsgMessage;
// use crate::core::botinstance::ChType::Channel;
@ -71,8 +73,18 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
;
let reply_parent_usr = if let Some(Some(reply)) = msg.source.tags.0.get("reply-thread-parent-user-login") {
Some(reply)
// let reply_parent_usr = if let Some(Some(reply)) = msg.source.tags.0.get("reply-thread-parent-user-login") {
// Some(reply)
// } else { None }
// ;
let reply_parent_ts = if let Some(Some(replyts)) = msg.source.tags.0.get("tmi-sent-ts") {
let a: i64 = replyts.parse().unwrap();
let b = Local.timestamp_millis_opt(a).unwrap();
// println!("Output : {}",b.to_string());
// println!("Formatted : {}",b.format("%m-%d %H:%M") );
Some(b.format("%m-%d %H:%M"))
} else { None }
;
@ -150,14 +162,33 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
[ ] Get Target Channel - trgchnl
*/
// reply_parent_ts
let newoutmsg = if let Some(srcmsg) = reply_parent {
format!("{} from #{} says {} . Replying to: {} : {}",
msg.sender.name,msg.channel_login,outmsg, reply_parent_usr.unwrap(),srcmsg)
// format!("{} from #{} says {} . Replying to: {} : {}",
// msg.sender.name,msg.channel_login,outmsg, reply_parent_usr.unwrap(),srcmsg)
// format!("{} from #{} says {} @ {} {} : {}",
// msg.sender.name,
// msg.channel_login,
// outmsg,
// reply_parent_ts.unwrap(),
// reply_parent_usr.unwrap(),
// srcmsg)
format!("{} {} @ {} : {}",
reply_parent_ts.unwrap(),
msg.sender.name,
msg.channel_login,
srcmsg)
} else {
format!("{} from #{} says : {}",
msg.sender.name,msg.channel_login, outmsg)
// format!("{} from #{} says : {}",
// msg.sender.name,
// msg.channel_login,
// outmsg)
format!("in {} - {} : {}",
msg.channel_login,
msg.sender.name,
outmsg)
};
// uses chat.say_in_reply_to() for the bot controls for messages