From 97d76ea088a00e8f9231be78db0dc5f1a9c05a13 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Sat, 23 Mar 2024 22:40:06 -0400 Subject: [PATCH] added ts to experiment --- Cargo.lock | 5 +-- Cargo.toml | 1 + src/custom/experimental/experiment002.rs | 43 ++++++++++++++++++++---- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18195c8..018b9dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/Cargo.toml b/Cargo.toml index 87f8cfa..f4c7751 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/custom/experimental/experiment002.rs b/src/custom/experimental/experiment002.rs index ff18642..2a97b30 100644 --- a/src/custom/experimental/experiment002.rs +++ b/src/custom/experimental/experiment002.rs @@ -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