From 235629be3768241c85cbc4f931212b8aca02d5f4 Mon Sep 17 00:00:00 2001 From: toast Date: Sat, 15 Feb 2025 21:08:25 +1100 Subject: [PATCH] Optimize iLO and remove unused stuff --- .gitattributes | 1 - Cargo.lock | 456 +++++++++++++++++-------------------- Cargo.toml | 14 +- Dockerfile | 4 +- cmds/Cargo.toml | 4 +- cmds/src/dispatch.rs | 4 +- cmds/src/dispatch/ilo.rs | 117 +++++----- cmds/src/dispatch/midi.rs | 113 --------- libs/assets/FluidR3_GM.sf2 | 3 - src/main.rs | 32 --- tasks/Cargo.toml | 18 -- tasks/src/lib.rs | 62 ----- tasks/src/rss.rs | 206 ----------------- tasks/src/rss/esxi.rs | 115 ---------- tasks/src/rss/github.rs | 144 ------------ tasks/src/rss/gportal.rs | 143 ------------ tasks/src/rss/processor.rs | 173 -------------- tasks/src/rss/rust.rs | 94 -------- tokens/Cargo.toml | 2 +- 19 files changed, 280 insertions(+), 1425 deletions(-) delete mode 100644 .gitattributes delete mode 100644 cmds/src/dispatch/midi.rs delete mode 100755 libs/assets/FluidR3_GM.sf2 delete mode 100644 tasks/Cargo.toml delete mode 100644 tasks/src/lib.rs delete mode 100644 tasks/src/rss.rs delete mode 100644 tasks/src/rss/esxi.rs delete mode 100644 tasks/src/rss/github.rs delete mode 100644 tasks/src/rss/gportal.rs delete mode 100644 tasks/src/rss/processor.rs delete mode 100644 tasks/src/rss/rust.rs diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 9a777c5..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -libs/assets/FluidR3_GM.sf2 filter=lfs diff=lfs merge=lfs -text diff --git a/Cargo.lock b/Cargo.lock index a48a61a..cfe6dea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,13 +58,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -119,9 +119,9 @@ dependencies = [ [[package]] name = "bb8-redis" -version = "0.18.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8416aa3639520757fd0ed659c8c12f7cd9f0ed638fa0cdd52a13d3b19946df2a" +checksum = "3428672918816ef7533c206902630ccaceebf69ca8831a30c18eacf5cb619070" dependencies = [ "bb8", "redis", @@ -135,9 +135,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "block-buffer" @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytecount" @@ -168,9 +168,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" [[package]] name = "camino" @@ -215,9 +215,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.6" +version = "1.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" dependencies = [ "shlex", ] @@ -236,10 +236,8 @@ checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", "serde", - "wasm-bindgen", "windows-targets 0.52.6", ] @@ -275,9 +273,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -356,7 +354,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -367,7 +365,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -385,10 +383,24 @@ dependencies = [ ] [[package]] -name = "data-encoding" -version = "2.6.0" +name = "dashmap" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" [[package]] name = "deranged" @@ -429,7 +441,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -449,9 +461,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -478,23 +490,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" -[[package]] -name = "feed-rs" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c0591d23efd0d595099af69a31863ac1823046b1b021e3b06ba3aae7e00991" -dependencies = [ - "chrono", - "mediatype", - "quick-xml", - "regex", - "serde", - "serde_json", - "siphasher", - "url", - "uuid", -] - [[package]] name = "flate2" version = "1.0.35" @@ -579,7 +574,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -639,7 +634,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.6", ] [[package]] @@ -762,9 +769,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" [[package]] name = "httpdate" @@ -798,9 +805,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -838,9 +845,9 @@ checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http 1.2.0", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-util", - "rustls 0.23.20", + "rustls 0.23.23", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -855,7 +862,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-util", "native-tls", "tokio", @@ -874,7 +881,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.2", + "hyper 1.6.0", "pin-project-lite", "socket2", "tokio", @@ -1020,7 +1027,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -1052,9 +1059,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -1062,18 +1069,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" - -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "itoa" @@ -1083,9 +1081,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -1093,11 +1091,10 @@ dependencies = [ [[package]] name = "kon" -version = "0.6.4" +version = "0.6.5" dependencies = [ "kon_cmds", "kon_libs", - "kon_tasks", "kon_tokens", "poise", "tokio", @@ -1105,13 +1102,13 @@ dependencies = [ [[package]] name = "kon_cmds" -version = "0.1.2" +version = "0.1.3" dependencies = [ + "dashmap 6.1.0", "kon_libs", "kon_tokens", "lazy_static", "poise", - "regex", "reqwest 0.12.12", "serde", "serde_json", @@ -1139,20 +1136,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "kon_tasks" -version = "0.1.2" -dependencies = [ - "feed-rs", - "kon_libs", - "kon_repo", - "once_cell", - "poise", - "regex", - "reqwest 0.12.12", - "tokio", -] - [[package]] name = "kon_tokens" version = "0.1.0" @@ -1175,9 +1158,9 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -1197,18 +1180,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "mediatype" -version = "0.19.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8878cd8d1b3c8c8ae4b2ba0a36652b7cf192f618a599a7fbdfa25cffd4ea72dd" -dependencies = [ - "serde", -] +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "memchr" @@ -1240,7 +1214,7 @@ checksum = "c325dfab65f261f386debee8b0969da215b3fa0037e74c8a1234db7ba986d803" dependencies = [ "crossbeam-channel", "crossbeam-utils", - "dashmap", + "dashmap 5.5.3", "skeptic", "smallvec", "tagptr", @@ -1249,9 +1223,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", ] @@ -1263,15 +1237,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] [[package]] name = "native-tls" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" dependencies = [ "libc", "log", @@ -1338,17 +1312,17 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "cfg-if", "foreign-types", "libc", @@ -1365,29 +1339,29 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-src" -version = "300.4.1+3.4.0" +version = "300.4.2+3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" +checksum = "168ce4e058f975fe43e89d9ccf78ca668601887ae736090aacc23ae353c298e2" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" dependencies = [ "cc", "libc", @@ -1427,9 +1401,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1469,7 +1443,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -1489,9 +1463,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1502,21 +1476,11 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "memchr", "unicase", ] -[[package]] -name = "quick-xml" -version = "0.37.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "165859e9e55f79d67b96c5d96f4e88b6f2695a1972849c15a6a3f5c59fc2c003" -dependencies = [ - "encoding_rs", - "memchr", -] - [[package]] name = "quote" version = "1.0.38" @@ -1553,7 +1517,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -1578,16 +1542,14 @@ dependencies = [ [[package]] name = "redis" -version = "0.27.6" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d8f99a4090c89cc489a94833c901ead69bfbf3877b4867d5482e321ee875bc" +checksum = "e37ec3fd44bea2ec947ba6cc7634d7999a6590aca7c35827c250bc0de502bda6" dependencies = [ "arc-swap", - "async-trait", "bytes", "combine", "futures-util", - "itertools", "itoa", "num-bigint", "percent-encoding", @@ -1604,7 +1566,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", ] [[package]] @@ -1695,7 +1657,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.2", + "hyper 1.6.0", "hyper-rustls 0.27.5", "hyper-tls", "hyper-util", @@ -1726,15 +1688,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.15", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -1747,11 +1708,11 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -1786,9 +1747,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ "once_cell", "rustls-pki-types", @@ -1817,9 +1778,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" [[package]] name = "rustls-webpki" @@ -1843,10 +1804,16 @@ dependencies = [ ] [[package]] -name = "ryu" -version = "1.0.18" +name = "rustversion" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + +[[package]] +name = "ryu" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "same-file" @@ -1898,7 +1865,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "core-foundation", "core-foundation-sys", "libc", @@ -1907,9 +1874,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -1917,9 +1884,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" +checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" dependencies = [ "serde", ] @@ -1950,14 +1917,14 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -1995,10 +1962,10 @@ dependencies = [ "arrayvec", "async-trait", "base64 0.22.1", - "bitflags 2.6.0", + "bitflags 2.8.0", "bytes", "chrono", - "dashmap", + "dashmap 5.5.3", "flate2", "futures", "fxhash", @@ -2045,12 +2012,6 @@ dependencies = [ "libc", ] -[[package]] -name = "siphasher" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" - [[package]] name = "skeptic" version = "0.13.7" @@ -2077,9 +2038,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" @@ -2091,12 +2052,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -2128,9 +2083,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.94" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -2160,7 +2115,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -2194,7 +2149,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "core-foundation", "system-configuration-sys 0.6.0", ] @@ -2227,13 +2182,13 @@ checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" dependencies = [ "cfg-if", "fastrand", - "getrandom", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -2256,7 +2211,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -2302,9 +2257,9 @@ dependencies = [ [[package]] name = "tokenservice-client" -version = "0.4.2" +version = "0.4.3" source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/" -checksum = "6c6f3da21601ea1072262024198c099bea1688714f13b13c36cc7f4a88c6b203" +checksum = "71e3aeafcfb59464d7350349b4f78e3c33a9700a7015e44a24492952ef28170b" dependencies = [ "reqwest 0.12.12", "serde", @@ -2314,9 +2269,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -2332,13 +2287,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -2378,7 +2333,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.20", + "rustls 0.23.23", "tokio", ] @@ -2395,7 +2350,7 @@ dependencies = [ "tokio", "tokio-rustls 0.25.0", "tungstenite", - "webpki-roots 0.26.7", + "webpki-roots 0.26.8", ] [[package]] @@ -2413,9 +2368,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -2434,9 +2389,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -2492,7 +2447,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -2557,12 +2512,12 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typesize" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "549e54551d85ba6718a95333d9bc4367f69793d7aba638de30f8d25a1f554a1d" +checksum = "20304d891be0766f52123746c721d1190b953e874f9eccf29067a64c1a0ae16c" dependencies = [ "chrono", - "dashmap", + "dashmap 5.5.3", "hashbrown 0.14.5", "mini-moka", "parking_lot", @@ -2575,13 +2530,13 @@ dependencies = [ [[package]] name = "typesize-derive" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9fc0ad9e03a2b0c2e2a0eafaecccef2121829e1ab6ce9c9d790e6c6766bd1c" +checksum = "536b6812192bda8551cfa0e52524e328c6a951b48e66529ee4522d6c721243d6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -2592,9 +2547,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "untrusted" @@ -2643,15 +2598,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" -[[package]] -name = "uuid" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" -dependencies = [ - "getrandom", -] - [[package]] name = "vcpkg" version = "0.2.15" @@ -2690,35 +2636,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasm-bindgen" -version = "0.2.99" +name = "wasi" +version = "0.13.3+wasi-0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -2729,9 +2685,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2739,22 +2695,25 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-streams" @@ -2771,9 +2730,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -2787,9 +2746,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.7" +version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" dependencies = [ "rustls-pki-types", ] @@ -2864,7 +2823,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -2875,7 +2834,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -3067,9 +3026,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.21" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] @@ -3084,6 +3043,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.8.0", +] + [[package]] name = "write16" version = "1.0.0" @@ -3116,7 +3084,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", "synstructure", ] @@ -3138,7 +3106,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] [[package]] @@ -3158,7 +3126,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", "synstructure", ] @@ -3187,5 +3155,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.94", + "syn 2.0.98", ] diff --git a/Cargo.toml b/Cargo.toml index 996d588..ea0b893 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,17 @@ [package] name = "kon" -version = "0.6.4" +version = "0.6.5" edition = "2024" [workspace] -members = ["cmds", "libs", "repo", "tasks", "tokens"] +members = ["cmds", "libs", "repo", "tokens"] [workspace.dependencies] bb8 = "0.9.0" -bb8-redis = "0.18.0" +bb8-redis = "0.20.0" cargo_toml = "0.21.0" -feed-rs = "2.3.1" -once_cell = "1.20.2" +dashmap = "6.1.0" poise = "0.6.1" -regex = "1.11.1" reqwest = { version = "0.12.12", features = ["json", "native-tls-vendored"] } serde = "1.0.217" serde_json = "1.0.134" @@ -28,7 +26,6 @@ kon_repo = { path = "repo" } [dependencies] kon_cmds = { path = "cmds" } kon_libs = { workspace = true } -kon_tasks = { path = "tasks" } kon_tokens = { workspace = true } poise = { workspace = true } tokio = { workspace = true } @@ -37,8 +34,7 @@ tokio = { workspace = true } poise = { git = "https://github.com/serenity-rs/poise", branch = "next" } [features] -production = ["kon_libs/production", "kon_tasks/production"] -rss = ["kon_tasks/rss"] +production = ["kon_libs/production"] [[bin]] name = "kon" diff --git a/Dockerfile b/Dockerfile index 37b7f92..42a7c80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ FROM scratch AS base WORKDIR /builder COPY . . -FROM alpine:3.21 +FROM adelielinux/adelie:1.0-beta6 LABEL org.opencontainers.image.source="https://git.toast-server.net/toast/Kon" -RUN apk add --no-cache libgcc fluidsynth +RUN apk add --no-cache libgcc WORKDIR /kon COPY --from=base /builder/target/x86_64-unknown-linux-musl/release/kon . CMD [ "./kon" ] diff --git a/cmds/Cargo.toml b/cmds/Cargo.toml index 6eb6b47..fdb83c9 100644 --- a/cmds/Cargo.toml +++ b/cmds/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kon_cmds" -version = "0.1.2" +version = "0.1.3" edition = "2024" [dependencies] @@ -8,10 +8,10 @@ kon_libs = { workspace = true } kon_tokens = { workspace = true } lazy_static = { workspace = true } poise = { workspace = true } -regex = { workspace = true } reqwest = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } sysinfo = { workspace = true } tokio = { workspace = true } uptime_lib = { workspace = true } +dashmap = { workspace = true } diff --git a/cmds/src/dispatch.rs b/cmds/src/dispatch.rs index 815cffc..ea4138a 100644 --- a/cmds/src/dispatch.rs +++ b/cmds/src/dispatch.rs @@ -1,5 +1,4 @@ mod ilo; -mod midi; mod status; mod uptime; @@ -12,7 +11,6 @@ use kon_libs::{ use { ilo::ilo, - midi::midi_to_wav, status::status, uptime::uptime }; @@ -23,7 +21,7 @@ macro_rules! commands { } } -pub fn register_cmds() -> Vec> { commands!(deploy, ping, ilo, midi_to_wav, status, uptime) } +pub fn register_cmds() -> Vec> { commands!(deploy, ping, ilo, status, uptime) } /// Deploy the commands globally or in a guild #[poise::command(prefix_command, owners_only, guild_only)] diff --git a/cmds/src/dispatch/ilo.rs b/cmds/src/dispatch/ilo.rs index 27fbc86..6929584 100644 --- a/cmds/src/dispatch/ilo.rs +++ b/cmds/src/dispatch/ilo.rs @@ -1,4 +1,5 @@ use { + dashmap::DashMap, kon_libs::{ BINARY_PROPERTIES, KonResult @@ -21,114 +22,117 @@ use { Deserialize, Serialize, de::DeserializeOwned - } + }, + tokio::time::Duration }; const ILO_HOSTNAME: &str = "POMNI"; lazy_static! { - static ref REQWEST_CLIENT: Client = ClientBuilder::new().danger_accept_invalid_certs(true).build().unwrap(); + static ref REQWEST_CLIENT: Client = ClientBuilder::new() + .danger_accept_invalid_certs(true) + .timeout(Duration::from_secs(15)) + .pool_max_idle_per_host(6) + .pool_idle_timeout(Some(Duration::from_secs(30))) + .tcp_keepalive(Duration::from_secs(600)) + .build() + .unwrap(); + static ref SENSOR_NAMES: DashMap<&'static str, &'static str> = { + let m = DashMap::new(); + m.insert("01-Inlet Ambient", "Inlet Ambient"); + m.insert("04-P1 DIMM 1-6", "P1 DIMM 1-6"); + m.insert("14-Chipset Zone", "Chipset Zone"); + m + }; + static ref POST_STATES: DashMap<&'static str, &'static str> = { + let m = DashMap::new(); + m.insert("FinishedPost", "Finished POST"); + m.insert("InPost", "In POST (Booting)"); + m.insert("PowerOff", "Powered off"); + m + }; } #[derive(Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] struct Chassis { - #[serde(rename = "Fans")] fans: Vec, - #[serde(rename = "Temperatures")] temperatures: Vec } #[derive(Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] struct Fan { - #[serde(rename = "CurrentReading")] current_reading: i32, - #[serde(rename = "FanName")] fan_name: String, - #[serde(rename = "Status")] status: Status } #[derive(Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] struct Temperature { - #[serde(rename = "CurrentReading")] current_reading: i32, - #[serde(rename = "Name")] name: String, - #[serde(rename = "ReadingCelsius")] reading_celsius: i32, - #[serde(rename = "Status")] status: Status, - #[serde(rename = "Units")] units: String, - #[serde(rename = "UpperThresholdCritical")] upper_threshold_critical: i32, - #[serde(rename = "UpperThresholdFatal")] upper_threshold_fatal: i32 } #[derive(Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] struct Status { - #[serde(rename = "Health")] health: Option, - #[serde(rename = "State")] state: String } #[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] struct Power { - #[serde(rename = "PowerCapacityWatts")] power_capacity_watts: i32, - #[serde(rename = "PowerConsumedWatts")] power_consumed_watts: i32, - #[serde(rename = "PowerMetrics")] power_metrics: PowerMetrics } #[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] struct PowerMetrics { - #[serde(rename = "AverageConsumedWatts")] average_consumed_watts: i32, - #[serde(rename = "MaxConsumedWatts")] max_consumed_watts: i32, - #[serde(rename = "MinConsumedWatts")] min_consumed_watts: i32 } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] struct System { - #[serde(rename = "Memory")] memory: Memory, - #[serde(rename = "Model")] model: String, - #[serde(rename = "Oem")] oem: Oem, - #[serde(rename = "PowerState")] power_state: String, - #[serde(rename = "ProcessorSummary")] processor_summary: ProcessorSummary } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] struct Memory { #[serde(rename = "TotalSystemMemoryGB")] - total_system_memory: i32 + total_system_memory_gb: i32 } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] struct ProcessorSummary { - #[serde(rename = "Count")] count: i32, - #[serde(rename = "Model")] - cpu: String + model: String } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] struct Oem { #[serde(rename = "Hp")] hp: Hp } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] struct Hp { #[serde(rename = "PostState")] post_state: String @@ -148,12 +152,10 @@ struct Iml { } #[derive(Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] struct ImlEntry { - #[serde(rename = "Created")] created: String, - #[serde(rename = "Message")] message: String, - #[serde(rename = "Severity")] severity: String } @@ -251,12 +253,7 @@ async fn temperature(ctx: super::PoiseCtx<'_>) -> KonResult<()> { continue; } - let name = match temp.name.as_str() { - "01-Inlet Ambient" => "Inlet Ambient", - "04-P1 DIMM 1-6" => "P1 DIMM 1-6", - "14-Chipset Zone" => "Chipset Zone", - _ => "Unknown Sensor" - }; + let name = SENSOR_NAMES.get(temp.name.as_str()).map(|s| *s).unwrap_or("Unknown sensor"); tempdata.push_str(&format!("**{name}:** `{}°C`\n", temp.reading_celsius)); } @@ -285,13 +282,14 @@ async fn power(ctx: super::PoiseCtx<'_>) -> KonResult<()> { ctx.defer().await?; let data: Power = ilo_data(RedfishEndpoint::Power).await?; - let mut powerdata = String::new(); - - powerdata.push_str(&format!("**Power Capacity:** `{}w`\n", &data.power_capacity_watts)); - powerdata.push_str(&format!("**Power Consumed:** `{}w`\n", &data.power_consumed_watts)); - powerdata.push_str(&format!("**Average Power:** `{}w`\n", &data.power_metrics.average_consumed_watts)); - powerdata.push_str(&format!("**Max Consumed:** `{}w`\n", &data.power_metrics.max_consumed_watts)); - powerdata.push_str(&format!("**Min Consumed:** `{}w`", &data.power_metrics.min_consumed_watts)); + let powerdata = format!( + "**Power Capacity:** `{}w`\n**Power Consumed:** `{}w`\n**Average Power:** `{}w`\n**Max Consumed:** `{}w`\n**Min Consumed:** `{}w`", + data.power_capacity_watts, + data.power_consumed_watts, + data.power_metrics.average_consumed_watts, + data.power_metrics.max_consumed_watts, + data.power_metrics.min_consumed_watts + ); ctx .send(CreateReply::default().embed(embed_builder("Power", Some(powerdata), None))) @@ -312,12 +310,11 @@ async fn system(ctx: super::PoiseCtx<'_>) -> KonResult<()> { let mut data = String::new(); - let post_state = match ilo_sys.oem.hp.post_state.as_str() { - "FinishedPost" => "Finished POST", - "InPost" => "In POST (Booting)", - "PowerOff" => "Powered off", - _ => "Unknown State" - }; + let post_state = POST_STATES + .get(ilo_sys.oem.hp.post_state.as_str()) + .map(|s| *s) + .unwrap_or("Unknown POST state"); + if ilo_sys.oem.hp.post_state != "FinishedPost" { println!("iLO:PostState = {}", ilo_sys.oem.hp.post_state); } @@ -337,10 +334,10 @@ async fn system(ctx: super::PoiseCtx<'_>) -> KonResult<()> { Some(vec![ ( format!("CPU ({}x)", ilo_sys.processor_summary.count), - ilo_sys.processor_summary.cpu.trim().to_string(), + ilo_sys.processor_summary.model.trim().to_string(), true ), - ("RAM".to_string(), format!("{} GB", ilo_sys.memory.total_system_memory), true), + ("RAM".to_string(), format!("{} GB", ilo_sys.memory.total_system_memory_gb), true), ]) ))) .await?; diff --git a/cmds/src/dispatch/midi.rs b/cmds/src/dispatch/midi.rs deleted file mode 100644 index c4d833f..0000000 --- a/cmds/src/dispatch/midi.rs +++ /dev/null @@ -1,113 +0,0 @@ -use { - kon_libs::{ - KonError, - KonResult, - format_bytes, - mention_dev - }, - poise::{ - CreateReply, - serenity_prelude::{ - CreateAttachment, - Message - } - }, - regex::Regex, - std::{ - fs::{ - metadata, - remove_file, - write - }, - os::unix::fs::MetadataExt - } -}; - -/// Convert MIDI file to WAV -#[poise::command( - context_menu_command = "MIDI -> WAV", - install_context = "Guild|User", - interaction_context = "Guild|BotDm|PrivateChannel" -)] -pub async fn midi_to_wav( - ctx: super::PoiseCtx<'_>, - #[description = "MIDI file to be converted"] message: Message -) -> KonResult<()> { - let re = Regex::new(r"(?i)\.mid$").unwrap(); - - if !message.embeds.is_empty() || message.attachments.is_empty() || !re.is_match(&message.attachments[0].filename) { - ctx.reply("That ain't a MIDI file! What are you even doing??").await?; - return Ok(()); - } - - ctx.defer().await?; - - let bytes = match message.attachments[0].download().await { - Ok(bytes) => bytes, - Err(y) => { - ctx - .send(CreateReply::default().content(format!( - "Download failed, ask {} to check console for more information!", - mention_dev(ctx).unwrap_or_default() - ))) - .await - .unwrap(); - - return Err(KonError::from(format!("Failed to download the file: {y}"))) - } - }; - - let midi_path = &message.attachments[0].filename; - write(midi_path, bytes)?; - - let wav_path = re.replace(midi_path, ".wav"); - - let sf2_path = "/tmp/FluidR3_GM.sf2"; - write(sf2_path, include_bytes!("../../../libs/assets/FluidR3_GM.sf2"))?; - - let output = std::process::Command::new("fluidsynth") - .args(["-ni", sf2_path, midi_path, "-F", &wav_path]) - .output(); - - // Just to add an info to console to tell what the bot is doing when MIDI file is downloaded. - println!("Discord[{}]: Processing MIDI file: \"{midi_path}\"", ctx.command().qualified_name); - - match output { - Ok(_) => { - let reply = ctx - .send(CreateReply::default().attachment(CreateAttachment::path(&*wav_path).await.unwrap())) - .await; - - if reply.is_err() { - println!( - "Discord[{}]: Processed file couldn't be uploaded back to Discord channel due to upload limit", - ctx.command().qualified_name - ); - - ctx - .send(CreateReply::default().content(format!( - "Couldn't upload the processed file (`{}`, `{}`) due to upload limit", - &*wav_path, - format_bytes(metadata(&*wav_path).unwrap().size()) - ))) - .await?; - } else if reply.is_ok() { - println!( - "Discord[{}]: Processed file uploaded back to Discord channel", - ctx.command().qualified_name - ); - remove_file(midi_path)?; - remove_file(&*wav_path)?; - } - }, - Err(y) => { - ctx - .send(CreateReply::default().content("Command didn't execute successfully, check console for more information!")) - .await?; - - return Err(KonError::from(format!("Midi conversion failed: {y}"))) - } - } - - Ok(()) -} diff --git a/libs/assets/FluidR3_GM.sf2 b/libs/assets/FluidR3_GM.sf2 deleted file mode 100755 index 14b4bfc..0000000 --- a/libs/assets/FluidR3_GM.sf2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:74594e8f4250680adf590507a306655a299935343583256f3b722c48a1bc1cb0 -size 148398306 diff --git a/src/main.rs b/src/main.rs index fc9e680..666e871 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,6 @@ // https://cdn.toast-server.net/RustFSHiearchy.png // Using the new filesystem hierarchy -#[cfg(feature = "rss")] -use { - kon_tasks::{ - rss, - run_task - }, - std::{ - sync::Arc, - thread::current - } -}; - use { kon_cmds::register_cmds, kon_libs::{ @@ -22,7 +10,6 @@ use { GIT_COMMIT_HASH, KonData, KonResult, - PoiseFwCtx, mention_dev }, kon_tokens::token_path, @@ -30,7 +17,6 @@ use { ChannelId, ClientBuilder, Context, - FullEvent, GatewayIntents, Ready, builder::{ @@ -70,23 +56,6 @@ async fn on_ready( Ok(KonData {}) } -async fn event_processor( - framework: PoiseFwCtx<'_>, - event: &FullEvent -) -> KonResult<()> { - #[cfg(feature = "rss")] - if let FullEvent::Ready { .. } = event { - let thread_id = format!("{:?}", current().id()); - let thread_num: String = thread_id.chars().filter(|c| c.is_ascii_digit()).collect(); - println!("Event[Ready]: Task Scheduler operating on thread {thread_num}"); - - let ctx = Arc::new(framework.serenity_context.clone()); - run_task(ctx.clone(), rss).await; - } - - Ok(()) -} - #[tokio::main] async fn main() { let prefix = if BINARY_PROPERTIES.env.contains("dev") { @@ -138,7 +107,6 @@ async fn main() { }) }, initialize_owners: true, - event_handler: |framework, event| Box::pin(event_processor(framework, event)), ..Default::default() }) .setup(|ctx, ready, _| Box::pin(on_ready(ctx, ready))) diff --git a/tasks/Cargo.toml b/tasks/Cargo.toml deleted file mode 100644 index 33f7022..0000000 --- a/tasks/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "kon_tasks" -version = "0.1.2" -edition = "2024" - -[dependencies] -feed-rs = { workspace = true } -kon_libs = { workspace = true } -kon_repo = { workspace = true } -once_cell = { workspace = true } -poise = { workspace = true } -regex = { workspace = true } -reqwest = { workspace = true } -tokio = { workspace = true } - -[features] -production = ["kon_libs/production"] -rss = [] diff --git a/tasks/src/lib.rs b/tasks/src/lib.rs deleted file mode 100644 index edb2c98..0000000 --- a/tasks/src/lib.rs +++ /dev/null @@ -1,62 +0,0 @@ -#[cfg(feature = "rss")] -mod rss; - -#[cfg(feature = "rss")] -pub use rss::rss; - -use { - kon_libs::KonResult, - poise::serenity_prelude::Context, - std::{ - future::Future, - sync::{ - Arc, - atomic::{ - AtomicBool, - Ordering - } - } - }, - tokio::task::spawn -}; - -#[cfg(feature = "rss")] -fn task_info( - name: &str, - message: &str -) { - println!("TaskScheduler[{name}]: {message}") -} - -#[cfg(feature = "rss")] -fn task_err( - name: &str, - message: &str -) { - eprintln!("TaskScheduler[{name}:Error]: {message}") -} - -static TASK_RUNNING: AtomicBool = AtomicBool::new(false); - -pub async fn run_task( - ctx: Arc, - task: F -) where - F: Fn(Arc) -> T + Send + 'static, - T: Future> + Send + 'static -{ - let ctx_cl = Arc::clone(&ctx); - - if !TASK_RUNNING.load(Ordering::SeqCst) { - TASK_RUNNING.store(true, Ordering::SeqCst); - spawn(async move { - if let Err(y) = task(ctx_cl).await { - eprintln!("TaskScheduler[Main:Error]: Failed to execute the task, error reason: {y}"); - if let Some(source) = y.source() { - eprintln!("TaskScheduler[Main:Error]: Failed to execute the task, this is caused by: {source:#?}"); - } - } - TASK_RUNNING.store(false, Ordering::SeqCst); - }); - } -} diff --git a/tasks/src/rss.rs b/tasks/src/rss.rs deleted file mode 100644 index c9fe50d..0000000 --- a/tasks/src/rss.rs +++ /dev/null @@ -1,206 +0,0 @@ -mod processor; // Process the feeds and send it off to Discord - -mod esxi; -mod github; -mod gportal; -mod rust; - -use { - esxi::Esxi, - github::GitHub, - gportal::GPortal, - rust::RustBlog -}; - -use super::{ - task_err, - task_info -}; - -use { - feed_rs::parser::parse, - kon_libs::{ - HttpClient, - KonResult - }, - kon_repo::RedisController, - once_cell::sync::OnceCell, - poise::serenity_prelude::{ - Context, - CreateEmbed, - Timestamp, - async_trait - }, - regex::Regex, - reqwest::Response, - std::sync::Arc, - tokio::time::{ - Duration, - interval - } -}; - -pub type RSSFeedBox = Box; - -const TASK_NAME: &str = "RSS"; -static REDIS_EXPIRY_SECS: i64 = 7200; -static REDIS_SERVICE: OnceCell> = OnceCell::new(); - -async fn redis_() { - let redis = RedisController::new().await.unwrap(); - REDIS_SERVICE.set(Arc::new(redis)).unwrap(); -} - -async fn get_redis() -> Arc { - if REDIS_SERVICE.get().is_none() { - redis_().await; - } - REDIS_SERVICE.get().unwrap().clone() -} - -fn format_href_to_discord(input: &str) -> String { - let re = Regex::new(r#"([^<]+)"#).unwrap(); - re.replace_all(input, r"[$2]($1)").to_string() -} - -fn format_html_to_discord(input: String) -> String { - let mut output = input; - - // Replace all instances of

and

with newlines - output = Regex::new(r#""#).unwrap().replace_all(&output, "\n").to_string(); - - // Replace all instances of
and
with newlines - output = Regex::new(r#"<\s*br\s*/?\s*>"#).unwrap().replace_all(&output, "\n").to_string(); - - // Replace all instances of with ** - output = Regex::new(r#""#).unwrap().replace_all(&output, "**").to_string(); - - // Replace all instances of and with nothing - output = Regex::new(r#""#).unwrap().replace_all(&output, "").to_string(); - - // Remove any other HTML tags - output = Regex::new(r#"<[^>]+>"#).unwrap().replace_all(&output, "").to_string(); - - // Replace all instances of text with [text](url) - output = format_href_to_discord(&output); - - output -} - -async fn fetch_feed(url: &str) -> KonResult { - let http = HttpClient::new(); - let res = match http.get(url, "RSS-Monitor").await { - Ok(res) => res, - Err(y) => return Err(y.into()) - }; - - Ok(res) -} - -async fn save_to_redis( - key: &str, - value: &str -) -> KonResult<()> { - let redis = get_redis().await; - redis.set(key, value).await.unwrap(); - if let Err(y) = redis.expire(key, REDIS_EXPIRY_SECS).await { - task_err("RSS", format!("[RedisExpiry]: {y}").as_str()); - } - Ok(()) -} - -fn embed( - color: u32, - title: String, - url: String, - description: String, - timestamp: Timestamp -) -> CreateEmbed { - CreateEmbed::new() - .color(color) - .title(title) - .url(url) - .description(description) - .timestamp(timestamp) -} - -const MAX_CONTENT_LENGTH: usize = 4000; -fn trim_old_content(s: &str) -> String { - if s.len() > MAX_CONTENT_LENGTH { - s[..MAX_CONTENT_LENGTH].to_string() - } else { - s.to_string() - } -} - -enum IncidentColorMap { - Update, - Investigating, - Monitoring, - Resolved, - Default -} - -impl IncidentColorMap { - fn color(&self) -> u32 { - match self { - Self::Update => 0xABDD9E, // Madang - Self::Investigating => 0xA5CCE0, // French Pass - Self::Monitoring => 0x81CBAD, // Monte Carlo - Self::Resolved => 0x57F287, // Emerald - Self::Default => 0x81CBAD // Monte Carlo - } - } -} - -#[async_trait] -pub trait RSSFeed { - fn name(&self) -> &str; - fn url(&self) -> &str; - async fn process( - &self, - ctx: Arc - ) -> KonResult>; -} - -/// Handle feed's output type for Discord message -pub enum RSSFeedOutput { - RegularEmbed(CreateEmbed), - IncidentEmbed(CreateEmbed), - Content(String) -} - -pub async fn rss(ctx: Arc) -> KonResult<()> { - #[cfg(feature = "production")] - let mut interval = interval(Duration::from_secs(300)); // Check feeds every 5 mins - #[cfg(not(feature = "production"))] - let mut interval = interval(Duration::from_secs(30)); // Check feeds every 30 secs - let mut first_run = true; - task_info(TASK_NAME, "Task loaded!"); - - let feeds: Vec = vec![ - Box::new(Esxi::new("https://esxi-patches.v-front.de/atom/ESXi-7.0.0.xml".to_string())), - Box::new(GitHub::new("https://www.githubstatus.com/history.atom".to_string())), - Box::new(GPortal::new("https://status.g-portal.com/history.atom".to_string())), - Box::new(RustBlog::new("https://blog.rust-lang.org/feed.xml".to_string())), - ]; - - let mut processor = processor::RSSProcessor::new(); - - for feed in feeds { - processor.add_feed(feed); - } - - loop { - interval.tick().await; - - if first_run { - task_info(&format!("{TASK_NAME}:Processor"), "Starting up!"); - first_run = false; - } - - if let Err(e) = processor.process_all(ctx.clone()).await { - task_err(&format!("{TASK_NAME}:Processor"), &e.to_string()); - } - } -} diff --git a/tasks/src/rss/esxi.rs b/tasks/src/rss/esxi.rs deleted file mode 100644 index c949fda..0000000 --- a/tasks/src/rss/esxi.rs +++ /dev/null @@ -1,115 +0,0 @@ -use super::{ - RSSFeed, - RSSFeedOutput, - fetch_feed, - format_href_to_discord, - get_redis, - parse, - save_to_redis, - task_err -}; - -use { - kon_libs::KonResult, - poise::serenity_prelude::{ - Context, - CreateEmbed, - CreateEmbedAuthor, - Timestamp, - async_trait - }, - regex::Regex, - std::{ - io::Cursor, - sync::Arc - } -}; - -pub struct Esxi { - url: String -} - -impl Esxi { - pub fn new(url: String) -> Self { Self { url } } -} - -#[async_trait] -impl RSSFeed for Esxi { - fn name(&self) -> &str { "ESXi" } - - fn url(&self) -> &str { self.url.as_str() } - - async fn process( - &self, - _ctx: Arc - ) -> KonResult> { - let redis = get_redis().await; - let rkey = "RSS_ESXi"; - - let res = fetch_feed(self.url()).await?; - let data = res.text().await?; - let cursor = Cursor::new(data); - - let feed = parse(cursor).map_err(|e| { - task_err("RSS:ESXi", &format!("Error parsing RSS feed: {e}")); - e - })?; - - if feed.entries.is_empty() { - task_err("RSS:ESXi", "No entries found in the feed!"); - return Ok(None); - } - - let home_page = feed.links[0].clone().href; - let article = feed.entries[0].clone(); - - fn get_patch_version(input: &str) -> Option { - let re = Regex::new(r#"(?i)Update\s+([0-9]+)([a-z]?)"#).unwrap(); - - if let Some(caps) = re.captures(input) { - let update_num = caps[1].to_string(); - let letter = caps.get(2).map_or("", |m| m.as_str()); - Some(format!("Update {update_num}{letter}")) - } else { - None - } - } - - let cached_patch = redis.get(rkey).await.unwrap_or(None).unwrap_or_default(); - - if cached_patch.is_empty() { - save_to_redis(rkey, &article.categories[3].term).await?; - return Ok(None); - } - - if let Some(patch) = get_patch_version(&article.categories[3].term) { - if patch == cached_patch { - Ok(None) - } else { - save_to_redis(rkey, &article.categories[3].term).await?; - - Ok(Some(RSSFeedOutput::RegularEmbed( - CreateEmbed::new() - .color(0x4EFBCB) - .author(CreateEmbedAuthor::new(feed.title.unwrap().content).url(home_page)) - .thumbnail(feed.logo.unwrap().uri) - .description(format!( - "{} {} for {} {} has been rolled out!\n{}", - article.categories[2].term, - article.categories[3].term, - article.categories[0].term, - article.categories[1].term, - format_href_to_discord(&article.summary.unwrap().content) - )) - .timestamp(Timestamp::from(article.updated.unwrap())) - ))) - } - } else { - task_err( - "RSS:ESXi", - &format!("Article term does not match the expected RegEx pattern! ({})", article.categories[3].term) - ); - Ok(None) - } - } -} diff --git a/tasks/src/rss/github.rs b/tasks/src/rss/github.rs deleted file mode 100644 index 951e16c..0000000 --- a/tasks/src/rss/github.rs +++ /dev/null @@ -1,144 +0,0 @@ -use super::{ - IncidentColorMap, - RSSFeed, - RSSFeedOutput, - embed, - fetch_feed, - format_html_to_discord, - get_redis, - parse, - save_to_redis, - task_err, - task_info, - trim_old_content -}; - -use { - kon_libs::KonResult, - poise::serenity_prelude::{ - Context, - Timestamp, - async_trait - }, - regex::Regex, - std::{ - io::Cursor, - sync::Arc - } -}; - -pub struct GitHub { - url: String -} - -impl GitHub { - pub fn new(url: String) -> Self { Self { url } } -} - -#[async_trait] -impl RSSFeed for GitHub { - fn name(&self) -> &str { "GitHub" } - - fn url(&self) -> &str { self.url.as_str() } - - async fn process( - &self, - _ctx: Arc - ) -> KonResult> { - let redis = get_redis().await; - let rkey = "RSS_GitHub"; - let rkey_content = format!("{rkey}_Content"); - - let res = fetch_feed(self.url()).await?; - let data = res.text().await?; - let cursor = Cursor::new(data); - - let feed = parse(cursor).map_err(|e| { - task_err("RSS:GitHub", &format!("Error parsing RSS feed: {e}")); - e - })?; - - if feed.entries.is_empty() { - task_err("RSS:GitHub", "No entries found in the feed!"); - return Ok(None); - } - - let incident_page = feed.entries[0].links[0].clone().href; - let article = feed.entries[0].clone(); - - fn get_incident_id(input: &str) -> Option { - let re = Regex::new(r#"/incidents/([a-zA-Z0-9]+)$"#).unwrap(); - re.captures(input).map(|caps| caps[1].to_string()) - } - - let cached_incident = redis.get(rkey).await.unwrap().unwrap_or_default(); - let new_content = format_html_to_discord(article.content.unwrap().body.unwrap()); - - let update_patt = Regex::new(r"(?i)\bupdate\b").unwrap(); - let investigating_patt = Regex::new(r"(?i)\binvestigating\b").unwrap(); - let resolved_patt = Regex::new(r"(?i)\bresolved\b").unwrap(); - let date_patt = Regex::new(r"\b[A-Z][a-z]{2} \d{2}, \d{2}:\d{2} UTC\b").unwrap(); - - let first_entry = date_patt - .split(&new_content) - .map(str::trim) - .find(|e| !e.is_empty()) - .unwrap_or(&new_content); - - let color: u32 = if update_patt.is_match(first_entry) { - IncidentColorMap::Update.color() - } else if investigating_patt.is_match(first_entry) { - IncidentColorMap::Investigating.color() - } else if resolved_patt.is_match(first_entry) { - IncidentColorMap::Resolved.color() - } else { - IncidentColorMap::Default.color() - }; - - task_info("RSS:GitHub:Debug", &format!("Checking cache for incident ID: {}", &article.links[0].href)); - if cached_incident.is_empty() { - save_to_redis(rkey, &get_incident_id(&article.links[0].href).unwrap()).await?; - save_to_redis(&rkey_content, &new_content).await?; - return Ok(None); - } - - if let Some(incident) = get_incident_id(&article.links[0].href) { - if incident == cached_incident { - let cached_content = redis.get(&rkey_content).await.unwrap().unwrap_or_default(); - if cached_content == new_content { - Ok(None) - } else { - redis.set(&rkey_content, &new_content).await.unwrap(); - redis.expire(&rkey_content, 21600).await.unwrap(); - task_info("RSS:GitHub:Debug", "Incident added in cache and preparing to send embed to Discord"); - - Ok(Some(RSSFeedOutput::IncidentEmbed(embed( - color, - article.title.unwrap().content, - incident_page, - trim_old_content(&new_content), - Timestamp::from(article.updated.unwrap()) - )))) - } - } else { - save_to_redis(rkey, &incident).await?; - redis.set(&rkey_content, &new_content).await.unwrap(); - task_info("RSS:GitHub:Debug", "Incident updated in cache and preparing to send embed to Discord"); - - Ok(Some(RSSFeedOutput::IncidentEmbed(embed( - color, - article.title.unwrap().content, - incident_page, - trim_old_content(&new_content), - Timestamp::from(article.updated.unwrap()) - )))) - } - } else { - task_err( - "RSS:GitHub", - &format!("Incident ID does not match the expected RegEx pattern! ({})", &article.links[0].href) - ); - Ok(None) - } - } -} diff --git a/tasks/src/rss/gportal.rs b/tasks/src/rss/gportal.rs deleted file mode 100644 index 999fbdb..0000000 --- a/tasks/src/rss/gportal.rs +++ /dev/null @@ -1,143 +0,0 @@ -use super::{ - IncidentColorMap, - RSSFeed, - RSSFeedOutput, - embed, - fetch_feed, - format_html_to_discord, - get_redis, - parse, - save_to_redis, - task_err, - trim_old_content -}; - -use { - kon_libs::KonResult, - poise::serenity_prelude::{ - Context, - Timestamp, - async_trait - }, - regex::Regex, - std::{ - io::Cursor, - sync::Arc - } -}; - -pub struct GPortal { - url: String -} - -impl GPortal { - pub fn new(url: String) -> Self { Self { url } } -} - -#[async_trait] -impl RSSFeed for GPortal { - fn name(&self) -> &str { "GPortal" } - - fn url(&self) -> &str { self.url.as_str() } - - async fn process( - &self, - _ctx: Arc - ) -> KonResult> { - let redis = get_redis().await; - let rkey = "RSS_GPortal"; - let rkey_content = format!("{rkey}_Content"); - - let res = fetch_feed(self.url()).await?; - let data = res.text().await?; - let cursor = Cursor::new(data); - - let feed = parse(cursor).map_err(|e| { - task_err("RSS:GPortal", &format!("Error parsing RSS feed: {e}")); - e - })?; - - if feed.entries.is_empty() { - task_err("RSS:GPortal", "No entries found in the feed!"); - return Ok(None); - } - - let incident_page = feed.links[0].clone().href; - let article = feed.entries[0].clone(); - - fn get_incident_id(input: &str) -> Option { - let re = Regex::new(r#"/incidents/([a-zA-Z0-9]+)$"#).unwrap(); - re.captures(input).map(|caps| caps[1].to_string()) - } - - let cached_incident = redis.get(rkey).await.unwrap().unwrap_or_default(); - let new_content = format_html_to_discord(article.content.unwrap().body.unwrap()); - - let update_patt = Regex::new(r"(?i)\bupdate\b").unwrap(); - let investigating_patt = Regex::new(r"(?i)\binvestigating\b").unwrap(); - let monitoring_patt = Regex::new(r"(?i)\bmonitoring\b").unwrap(); - let resolved_patt = Regex::new(r"(?i)\bresolved\b").unwrap(); - let date_patt = Regex::new(r"\b[A-Z][a-z]{2} \d{2}, \d{2}:\d{2} UTC\b").unwrap(); - - let first_entry = date_patt - .split(&new_content) - .map(str::trim) - .find(|e| !e.is_empty()) - .unwrap_or(&new_content); - - let color: u32 = if update_patt.is_match(first_entry) { - IncidentColorMap::Update.color() - } else if investigating_patt.is_match(first_entry) { - IncidentColorMap::Investigating.color() - } else if monitoring_patt.is_match(first_entry) { - IncidentColorMap::Monitoring.color() - } else if resolved_patt.is_match(first_entry) { - IncidentColorMap::Resolved.color() - } else { - IncidentColorMap::Default.color() - }; - - if cached_incident.is_empty() { - save_to_redis(rkey, &get_incident_id(&article.links[0].href).unwrap()).await?; - save_to_redis(&rkey_content, &new_content).await?; - return Ok(None); - } - - if let Some(incident) = get_incident_id(&article.links[0].href) { - if incident == cached_incident { - let cached_content = redis.get(&rkey_content).await.unwrap().unwrap_or_default(); - if cached_content == new_content { - Ok(None) - } else { - redis.set(&rkey_content, &new_content).await.unwrap(); - redis.expire(&rkey_content, 21600).await.unwrap(); - - Ok(Some(RSSFeedOutput::IncidentEmbed(embed( - color, - article.title.unwrap().content, - incident_page, - trim_old_content(&new_content), - Timestamp::from(article.updated.unwrap()) - )))) - } - } else { - save_to_redis(rkey, &incident).await?; - redis.set(&rkey_content, &new_content).await.unwrap(); - - Ok(Some(RSSFeedOutput::IncidentEmbed(embed( - color, - article.title.unwrap().content, - incident_page, - trim_old_content(&new_content), - Timestamp::from(article.updated.unwrap()) - )))) - } - } else { - task_err( - "RSS:GPortal", - &format!("Incident ID does not match the expected RegEx pattern! ({})", &article.links[0].href) - ); - Ok(None) - } - } -} diff --git a/tasks/src/rss/processor.rs b/tasks/src/rss/processor.rs deleted file mode 100644 index c164308..0000000 --- a/tasks/src/rss/processor.rs +++ /dev/null @@ -1,173 +0,0 @@ -use kon_libs::{ - BINARY_PROPERTIES, - KonResult -}; - -use super::{ - RSSFeedBox, - RSSFeedOutput, - TASK_NAME, - get_redis -}; - -use { - poise::serenity_prelude::{ - ChannelId, - Context, - CreateEmbed, - CreateMessage, - EditMessage, - Http - }, - regex::Regex, - std::sync::Arc -}; - -// This is for building up the embed with the feed data -/* std::fs::File::create("rss_name.log").unwrap(); -std::fs::write("rss_name.log", format!("{:#?}", feed))?; */ - -async fn process_regular_embed( - http: &Http, - embed: CreateEmbed, - redis_key: &str -) -> KonResult<()> { - let redis = get_redis().await; - let channel = ChannelId::new(BINARY_PROPERTIES.rss_channel); - - let msg_id_key: Option = redis.get(redis_key).await?; - - if let Some(msg_id_key) = msg_id_key { - if let Ok(msg_id) = msg_id_key.parse::() { - if let Ok(mut message) = channel.message(http, msg_id).await { - message.edit(http, EditMessage::new().embed(embed)).await?; - } - } - } else { - let message = channel.send_message(http, CreateMessage::new().add_embed(embed)).await?; - redis.set(redis_key, &message.id.to_string()).await?; - redis.expire(redis_key, 36000).await?; - } - - Ok(()) -} - -/// Cache-based embed updater for ongoing outages/incidents -async fn process_incident_embed( - http: &Http, - embed: CreateEmbed, - redis_key: &str, - content_key: &str -) -> KonResult<()> { - let redis = get_redis().await; - let channel = ChannelId::new(BINARY_PROPERTIES.rss_channel); - - let msg_id_key: Option = redis.get(redis_key).await?; - let cached_content: Option = redis.get(content_key).await.unwrap_or(None); - - if let Some(msg_id_key) = msg_id_key { - if let Ok(msg_id) = msg_id_key.parse::() { - if let Ok(mut message) = channel.message(http, msg_id).await { - if let Some(existing) = message.embeds.first() { - let new_description = existing.description.clone().unwrap(); - - if cached_content.as_deref() != Some(&new_description) { - message.edit(http, EditMessage::new().embed(embed)).await?; - } - - if Regex::new(r"(?i)^Resolved\s*-").unwrap().is_match(&new_description) { - redis.del(redis_key).await?; - } - } - } - } - } else { - let message = channel.send_message(http, CreateMessage::new().add_embed(embed)).await?; - redis.set(redis_key, &message.id.to_string()).await?; - redis.expire(redis_key, 36000).await?; - } - - Ok(()) -} - -/// Process the content string -async fn process_msg_content( - http: &Http, - content: String, - redis_key: &str -) -> KonResult<()> { - let redis = get_redis().await; - let channel = ChannelId::new(BINARY_PROPERTIES.rss_channel); - - let msg_id_key: Option = redis.get(redis_key).await?; - - if let Some(msg_id_key) = msg_id_key { - if let Ok(msg_id) = msg_id_key.parse::() { - channel.edit_message(http, msg_id, EditMessage::new().content(content)).await?; - } - } else { - let message = channel.send_message(http, CreateMessage::new().content(content)).await?; - redis.set(redis_key, &message.id.to_string()).await?; - redis.expire(redis_key, 36000).await?; - } - - Ok(()) -} - -pub struct RSSProcessor { - pub feeds: Vec -} - -impl RSSProcessor { - pub fn new() -> Self { Self { feeds: Vec::new() } } - - pub fn add_feed( - &mut self, - feed: RSSFeedBox - ) { - self.feeds.push(feed); - } - - pub async fn process_all( - &self, - ctx: Arc - ) -> KonResult<()> { - let mut discord_msg: Vec = Vec::new(); - - for feed in &self.feeds { - let feed_name = feed.name(); - let redis_key = format!("RSS_{feed_name}_MsgId"); - let error_msg = format!("**[{TASK_NAME}:{feed_name}:Error]:** Feed failed with the following error:```\n{{ error }}\n```"); - - match feed.process(ctx.clone()).await { - Ok(Some(output)) => match output { - RSSFeedOutput::RegularEmbed(embed) => { - if let Err(e) = process_regular_embed(&ctx.http, embed, &redis_key).await { - discord_msg.push(error_msg.replace("{{ error }}", &e.to_string())) - } - }, - RSSFeedOutput::IncidentEmbed(embed) => { - if let Err(e) = process_incident_embed(&ctx.http, embed, &redis_key, &format!("RSS_{feed_name}_Content")).await { - discord_msg.push(error_msg.replace("{{ error }}", &e.to_string())) - } - }, - RSSFeedOutput::Content(content) => { - if let Err(e) = process_msg_content(&ctx.http, content, &redis_key).await { - discord_msg.push(error_msg.replace("{{ error }}", &e.to_string())) - } - }, - }, - Ok(None) => (), - Err(e) => discord_msg.push(error_msg.replace("{{ error }}", &e.to_string())) - } - } - - if !discord_msg.is_empty() { - ChannelId::new(BINARY_PROPERTIES.kon_logs) - .send_message(&ctx.http, CreateMessage::new().content(discord_msg.join("\n"))) - .await?; - } - - Ok(()) - } -} diff --git a/tasks/src/rss/rust.rs b/tasks/src/rss/rust.rs deleted file mode 100644 index 60864af..0000000 --- a/tasks/src/rss/rust.rs +++ /dev/null @@ -1,94 +0,0 @@ -use super::{ - RSSFeed, - RSSFeedOutput, - fetch_feed, - get_redis, - parse, - save_to_redis, - task_err -}; - -use { - kon_libs::KonResult, - poise::serenity_prelude::{ - Context, - async_trait - }, - regex::Regex, - std::{ - io::Cursor, - sync::Arc - } -}; - -pub struct RustBlog { - url: String -} - -impl RustBlog { - pub fn new(url: String) -> Self { Self { url } } -} - -#[async_trait] -impl RSSFeed for RustBlog { - fn name(&self) -> &str { "RustBlog" } - - fn url(&self) -> &str { self.url.as_str() } - - async fn process( - &self, - _ctx: Arc - ) -> KonResult> { - let redis = get_redis().await; - let rkey = "RSS_RustBlog"; - - let res = fetch_feed(self.url()).await?; - let data = res.text().await?; - let cursor = Cursor::new(data); - - let feed = parse(cursor).map_err(|e| { - task_err("RSS:RustBlog", &format!("Error parsing RSS feed: {e}")); - e - })?; - - if feed.entries.is_empty() { - task_err("RSS:RustBlog", "No entries found in the feed!"); - return Ok(None); - } - - let article = feed.entries[0].clone(); - let article_id = article.id.clone(); - - fn get_blog_title(input: String) -> Option { - let re = Regex::new(r"https://blog\.rust-lang\.org/(\d{4}/\d{2}/\d{2}/[^/]+)").unwrap(); - re.captures(input.as_str()).and_then(|caps| caps.get(1).map(|m| m.as_str().to_string())) - } - - let cached_blog = redis.get(rkey).await.unwrap_or(None).unwrap_or_default(); - - if cached_blog.is_empty() { - save_to_redis(rkey, &get_blog_title(article.id).unwrap()).await?; - return Ok(None); - } - - if let Some(blog_title) = get_blog_title(article.id) { - if blog_title == cached_blog { - Ok(None) - } else { - save_to_redis(rkey, &blog_title).await?; - - Ok(Some(RSSFeedOutput::Content(format!( - "Rust Team has put out a new article!\n**[{}](<{}>)**", - article.links[0].title.clone().unwrap(), - article.links[0].href - )))) - } - } else { - task_err( - "RSS:RustBlog", - &format!("Article URL does not match the expected RegEx pattern! ({article_id})") - ); - Ok(None) - } - } -} diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index 523c2f3..02ee2d5 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -4,5 +4,5 @@ version = "0.1.0" edition = "2024" [dependencies] -tokenservice-client = { version = "0.4.1", registry = "gitea" } +tokenservice-client = { version = "0.4.3", registry = "gitea" } tokio = { workspace = true }