From 38f2be08e4860aaffd2e578f3dddf59f76c5cf22 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 7 Jan 2022 20:36:05 +0100 Subject: [PATCH] Fix uptime information in status command Signed-off-by: trivernis --- Cargo.lock | 126 +++++++++++++++++-------------- Cargo.toml | 7 +- src/commands/misc/stats.rs | 8 +- src/providers/music/responses.rs | 3 + 4 files changed, 82 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e9ee73..6e96fd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" dependencies = [ "proc-macro2", "quote", @@ -232,11 +232,24 @@ dependencies = [ "tokio-diesel", ] +[[package]] +name = "build-time" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1903cc3455e5cc187bd0e2cacad7de3b3fd8352b71c538039c3813bc713b2a40" +dependencies = [ + "chrono", + "once_cell", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "byteorder" @@ -575,9 +588,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "encoding_rs" -version = "0.8.29" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if 1.0.0", ] @@ -779,9 +792,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -822,9 +835,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.7" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd819562fcebdac5afc5c113c3ec36f902840b70fd4fc458799c8ce4607ae55" +checksum = "0c9de88456263e249e241fcd211d3954e2c9b0ef7ccfc235a444eb367cae3689" dependencies = [ "bytes 1.1.0", "fnv", @@ -870,13 +883,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes 1.1.0", "fnv", - "itoa 0.4.8", + "itoa 1.0.1", ] [[package]] @@ -904,9 +917,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.15" +version = "0.14.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" +checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" dependencies = [ "bytes 1.1.0", "futures-channel", @@ -936,7 +949,7 @@ dependencies = [ "hyper", "rustls 0.20.2", "tokio", - "tokio-rustls 0.23.1", + "tokio-rustls 0.23.2", ] [[package]] @@ -1188,9 +1201,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] @@ -1357,9 +1370,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", @@ -1367,9 +1380,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "opaque-debug" @@ -1399,9 +1412,9 @@ checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-sys" -version = "0.9.71" +version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df13d165e607909b363a4757a6f133f8a818a74e9d3a98d09c6128e15fa4c73" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ "autocfg", "cc", @@ -1545,18 +1558,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ "proc-macro2", "quote", @@ -1565,9 +1578,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -1577,9 +1590,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] name = "pnet_base" @@ -1621,9 +1634,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "pq-sys" @@ -1648,18 +1661,18 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" dependencies = [ "proc-macro2", ] @@ -1858,7 +1871,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-rustls 0.23.1", + "tokio-rustls 0.23.2", "tokio-util", "url", "wasm-bindgen", @@ -1947,15 +1960,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "ryu" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "salsa20" @@ -2315,9 +2328,9 @@ dependencies = [ [[package]] name = "songbird" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62492c36b6d3ddb342172f57fee6761388062b2b55ab3895aad0b554e51094e7" +checksum = "37584eec8ef3a793f51aa2f7093476904bd83475f3fa4fb786145c226a0e3f5e" dependencies = [ "async-trait", "async-tungstenite 0.14.0", @@ -2447,9 +2460,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.82" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" dependencies = [ "proc-macro2", "quote", @@ -2458,9 +2471,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.22.4" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb37aa4af23791c584202d286ed9420e023e9d27e49d5a76215623f4bcc2502" +checksum = "7f1bfab07306a27332451a662ca9c8156e3a9986f82660ba9c8e744fe8455d43" dependencies = [ "cfg-if 1.0.0", "core-foundation-sys", @@ -2550,12 +2563,13 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tobi-rs" -version = "0.9.9" +version = "0.9.10" dependencies = [ "animethemes-rs", "aspotify", "bot-coreutils", "bot-database", + "build-time", "chrono", "chrono-tz", "colored", @@ -2650,9 +2664,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4baa378e417d780beff82bf54ceb0d195193ea6a00c14e22359e7f39456b5689" +checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" dependencies = [ "rustls 0.20.2", "tokio", @@ -2809,9 +2823,9 @@ checksum = "ed5b74f0a24b5454580a79abb6994393b09adf0ab8070f15827cb666255de155" [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "uncased" @@ -2921,9 +2935,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "want" diff --git a/Cargo.toml b/Cargo.toml index 9f8914b..f5d4928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members=["bot-coreutils", "bot-database", "."] [package] name = "tobi-rs" -version = "0.9.9" +version = "0.9.10" authors = ["trivernis "] edition = "2018" @@ -22,7 +22,7 @@ serde_derive = "1.0.133" serde = "1.0.133" thiserror = "1.0.30" minecraft-data-rs = "0.4.1" -songbird = "0.2.0" +songbird = "0.2.1" serde_json = "1.0.74" rand = "0.8.4" regex = "1.5.4" @@ -33,7 +33,7 @@ log = "0.4.14" fern = "0.6.0" chrono = "0.4.19" colored = "2.0.0" -sysinfo = "0.22.4" +sysinfo = "0.22.5" reqwest = "0.11.8" chrono-tz = "0.6.1" sauce-api = "0.9.1" @@ -43,6 +43,7 @@ typemap_rev = "0.1.5" youtube-metadata = "0.2.0" xkcd-search = "0.1.2" animethemes-rs = "0.3.0" +build-time = "0.1.1" [dependencies.tokio] version = "1.15.0" diff --git a/src/commands/misc/stats.rs b/src/commands/misc/stats.rs index d982438..f520198 100644 --- a/src/commands/misc/stats.rs +++ b/src/commands/misc/stats.rs @@ -22,6 +22,7 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult { system.refresh_all(); let kernel_version = system.kernel_version().unwrap_or("n/a".to_string()); + //system.refresh_process(process::id() as i32); let own_process = system.process(process::id() as i32).unwrap(); let memory_usage = own_process.memory(); let cpu_usage = own_process.cpu_usage(); @@ -30,9 +31,8 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult { let guild_count: usize = current_user.guilds(ctx).await?.len(); let bot_info = ctx.http.get_current_application_info().await?; - let current_time_seconds = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); - let uptime = current_time_seconds - Duration::from_secs(own_process.start_time()); - let uptime = ChronoDuration::from_std(uptime).unwrap(); + let uptime = own_process.run_time(); + let uptime = ChronoDuration::from_std(Duration::from_secs(uptime)).unwrap(); let total_commands_executed = database.get_total_commands_statistic().await?; let shard_count = ctx.cache.shard_count().await; @@ -40,6 +40,7 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult { r#" Version: {} Compiled with: rustc {} + Build at: {} Owner: <@{}> Guilds: {} Shards: {} @@ -48,6 +49,7 @@ async fn stats(ctx: &Context, msg: &Message) -> CommandResult { "#, crate::VERSION, rustc_version_runtime::version(), + build_time::build_time_utc!("%Y-%m-%dT%H:%M:%S"), bot_info.owner.id, guild_count, shard_count, diff --git a/src/providers/music/responses.rs b/src/providers/music/responses.rs index 079930f..1f255fd 100644 --- a/src/providers/music/responses.rs +++ b/src/providers/music/responses.rs @@ -2,7 +2,9 @@ use serde_derive::Deserialize; #[derive(Deserialize, Clone, Debug)] pub(crate) struct PlaylistEntry { + #[allow(dead_code)] ie_key: String, + #[allow(dead_code)] id: String, pub url: String, pub title: String, @@ -11,6 +13,7 @@ pub(crate) struct PlaylistEntry { #[derive(Deserialize, Clone, Debug)] pub(crate) struct VideoInformation { + #[allow(dead_code)] pub(crate) id: String, pub title: String, pub thumbnail: Option,