From 3aa541c3e20468cb5af725f4f785a5afdd966d61 Mon Sep 17 00:00:00 2001 From: notohh Date: Fri, 7 Jun 2024 22:28:08 -0400 Subject: [PATCH] flesh out ping message --- src/commands.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index e41378f..abe288e 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,4 +1,5 @@ use crate::client::create_client; +use sysinfo::System; use twitch_irc::{ login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient, @@ -9,10 +10,25 @@ pub async fn ping(m: &PrivmsgMessage) { let (mut _incoming_messages, client) = TwitchIRCClient::::new(client); + let mut sys = System::new_all(); + sys.refresh_all(); - let s = format!("Pong!"); + let pid = sysinfo::get_current_pid().unwrap(); - let _message = client.say(m.channel_login.to_owned(), s.to_owned()).await; + if let Some(process) = sys.process(pid) { + let process_memory = process.memory(); + let total_memory = sys.total_memory(); + let mem = (process_memory as f64 / total_memory as f64) * 100.0; + let cpu = process.cpu_usage().round(); + let uptime = process.run_time(); + + let host = System::name().unwrap(); + let s = format!( + "Pong! | ↑: {}s | Host: {:?} | Mem: {:.2}% | CPU: {:?}%", + uptime, host, mem, cpu + ); + let _message = client.say(m.channel_login.to_owned(), s.to_owned()).await; + } } pub async fn test(m: &PrivmsgMessage) {