flesh out ping message
This commit is contained in:
parent
493995b280
commit
3aa541c3e2
1 changed files with 18 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
use crate::client::create_client;
|
use crate::client::create_client;
|
||||||
|
use sysinfo::System;
|
||||||
|
|
||||||
use twitch_irc::{
|
use twitch_irc::{
|
||||||
login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient,
|
login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient,
|
||||||
|
@ -9,10 +10,25 @@ pub async fn ping(m: &PrivmsgMessage) {
|
||||||
|
|
||||||
let (mut _incoming_messages, client) =
|
let (mut _incoming_messages, client) =
|
||||||
TwitchIRCClient::<SecureTCPTransport, StaticLoginCredentials>::new(client);
|
TwitchIRCClient::<SecureTCPTransport, StaticLoginCredentials>::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) {
|
pub async fn test(m: &PrivmsgMessage) {
|
||||||
|
|
Loading…
Reference in a new issue