diff --git a/Cargo.lock b/Cargo.lock index 4617fd0..77cfa72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,6 +88,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -172,6 +178,9 @@ name = "arrayvec" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +dependencies = [ + "serde", +] [[package]] name = "as-raw-xcb-connection" @@ -199,22 +208,6 @@ dependencies = [ "syn 2.0.61", ] -[[package]] -name = "async-tungstenite" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b71b31561643aa8e7df3effe284fa83ab1a840e52294c5f4bd7bfd8b2becbb" -dependencies = [ - "futures-io", - "futures-util", - "log", - "pin-project-lite", - "tokio", - "tokio-rustls 0.23.4", - "tungstenite", - "webpki-roots 0.22.6", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -297,12 +290,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -425,6 +412,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytecount" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" + [[package]] name = "bytemuck" version = "1.15.0" @@ -483,6 +476,37 @@ dependencies = [ "wayland-client", ] +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", +] + [[package]] name = "cc" version = "1.0.97" @@ -524,6 +548,19 @@ dependencies = [ "serde", ] +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.5", +] + [[package]] name = "clap" version = "4.5.4" @@ -543,7 +580,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.1", ] [[package]] @@ -689,6 +726,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -741,6 +787,61 @@ dependencies = [ "winapi", ] +[[package]] +name = "darling" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn 2.0.61", +] + +[[package]] +name = "darling_macro" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.61", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", + "serde", +] + +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "deranged" version = "0.3.11" @@ -751,6 +852,17 @@ dependencies = [ "serde", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.10.7" @@ -849,6 +961,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -889,7 +1010,7 @@ dependencies = [ "futures-core", "futures-sink", "nanorand", - "spin 0.9.8", + "spin", ] [[package]] @@ -1023,6 +1144,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1094,6 +1224,12 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "glow" version = "0.13.1" @@ -1413,6 +1549,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icrate" version = "0.0.4" @@ -1430,6 +1589,12 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -1672,6 +1837,21 @@ dependencies = [ "unicase", ] +[[package]] +name = "mini-moka" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c325dfab65f261f386debee8b0969da215b3fa0037e74c8a1234db7ba986d803" +dependencies = [ + "crossbeam-channel", + "crossbeam-utils", + "dashmap", + "skeptic", + "smallvec", + "tagptr", + "triomphe", +] + [[package]] name = "minifier" version = "0.3.0" @@ -1875,15 +2055,6 @@ dependencies = [ "libredox", ] -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - [[package]] name = "owned_ttf_parser" version = "0.21.0" @@ -2011,6 +2182,35 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "poise" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1819d5a45e3590ef33754abce46432570c54a120798bdbf893112b4211fa09a6" +dependencies = [ + "async-trait", + "derivative", + "futures-util", + "parking_lot", + "poise_macros", + "regex", + "serenity", + "tokio", + "tracing", +] + +[[package]] +name = "poise_macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa2c123c961e78315cd3deac7663177f12be4460f5440dbf62a7ed37b1effea" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "polling" version = "3.7.0" @@ -2068,6 +2268,17 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +[[package]] +name = "pulldown-cmark" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" +dependencies = [ + "bitflags 2.5.0", + "memchr", + "unicase", +] + [[package]] name = "quick-error" version = "2.0.1" @@ -2266,21 +2477,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.8" @@ -2291,8 +2487,8 @@ dependencies = [ "cfg-if", "getrandom", "libc", - "spin 0.9.8", - "untrusted 0.9.0", + "spin", + "untrusted", "windows-sys 0.52.0", ] @@ -2300,7 +2496,7 @@ dependencies = [ name = "rukaidata_bot" version = "0.1.0" dependencies = [ - "serenity", + "poise", "time", "tokio", ] @@ -2359,26 +2555,28 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.9" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", - "ring 0.16.20", + "ring", + "rustls-webpki 0.101.7", "sct", - "webpki", ] [[package]] name = "rustls" -version = "0.21.12" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", - "ring 0.17.8", - "rustls-webpki", - "sct", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.3", + "subtle", + "zeroize", ] [[package]] @@ -2390,14 +2588,31 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + [[package]] name = "rustls-webpki" version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -2439,8 +2654,8 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", + "ring", + "untrusted", ] [[package]] @@ -2457,24 +2672,33 @@ dependencies = [ ] [[package]] -name = "serde" -version = "1.0.201" +name = "secrecy" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" dependencies = [ - "serde_derive", + "serde", + "zeroize", ] [[package]] -name = "serde-value" -version = "0.7.0" +name = "semver" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ - "ordered-float", "serde", ] +[[package]] +name = "serde" +version = "1.0.201" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +dependencies = [ + "serde_derive", +] + [[package]] name = "serde_derive" version = "1.0.201" @@ -2521,37 +2745,41 @@ dependencies = [ [[package]] name = "serenity" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246008828de84241202b092316c4729da36c3edd8f0c17ed6893df8e414c3c9b" +checksum = "c64da29158bb55d70677cacd4f4f8eab1acef005fb830d9c3bea411b090e96a9" dependencies = [ + "arrayvec", "async-trait", - "async-tungstenite", - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.7", + "bitflags 2.5.0", "bytes", - "cfg-if", + "chrono", + "dashmap", "flate2", "futures", - "mime", + "fxhash", "mime_guess", + "parking_lot", "percent-encoding", "reqwest", + "secrecy", "serde", - "serde-value", "serde_json", "time", "tokio", + "tokio-tungstenite", "tracing", "typemap_rev", + "typesize", "url", ] [[package]] -name = "sha-1" -version = "0.10.1" +name = "sha1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -2578,6 +2806,21 @@ dependencies = [ "libc", ] +[[package]] +name = "skeptic" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" +dependencies = [ + "bytecount", + "cargo_metadata", + "error-chain", + "glob", + "pulldown-cmark", + "tempfile", + "walkdir", +] + [[package]] name = "slab" version = "0.4.9" @@ -2646,12 +2889,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -2689,6 +2926,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strsim" version = "0.11.1" @@ -2705,6 +2948,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -2760,6 +3009,12 @@ dependencies = [ "libc", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "tempfile" version = "3.10.1" @@ -2904,23 +3159,39 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.20.9", + "rustls 0.21.12", "tokio", - "webpki", ] [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.21.12", + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "rustls 0.22.4", + "rustls-pki-types", "tokio", + "tokio-rustls 0.25.0", + "tungstenite", + "webpki-roots 0.26.1", ] [[package]] @@ -3037,6 +3308,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" + [[package]] name = "try-lock" version = "0.2.5" @@ -3051,30 +3328,30 @@ checksum = "eb71ffab0ca84cecd986dd52e873c8d0b013f3d5d9ce25a6f7d0513ed933d562" [[package]] name = "tungstenite" -version = "0.17.3" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ - "base64 0.13.1", "byteorder", "bytes", - "http 0.2.12", + "data-encoding", + "http 1.1.0", "httparse", "log", "rand", - "rustls 0.20.9", - "sha-1", + "rustls 0.22.4", + "rustls-pki-types", + "sha1", "thiserror", "url", "utf-8", - "webpki", ] [[package]] name = "typemap_rev" -version = "0.1.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5b74f0a24b5454580a79abb6994393b09adf0ab8070f15827cb666255de155" +checksum = "74b08b0c1257381af16a5c3605254d529d3e7e109f3c62befc5d168968192998" [[package]] name = "typenum" @@ -3082,6 +3359,35 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typesize" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb704842c709bc76f63e99e704cb208beeccca2abbabd0d9aec02e48ca1cee0f" +dependencies = [ + "chrono", + "dashmap", + "hashbrown 0.14.5", + "mini-moka", + "parking_lot", + "secrecy", + "serde_json", + "time", + "typesize-derive", + "url", +] + +[[package]] +name = "typesize-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "905e88c2a4cc27686bd57e495121d451f027e441388a67f773be729ad4be1ea8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "ucd-trie" version = "0.1.6" @@ -3136,12 +3442,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -3540,30 +3840,20 @@ dependencies = [ ] [[package]] -name = "webpki" -version = "0.22.4" +name = "webpki-roots" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.8", - "untrusted 0.9.0", -] +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.22.6" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" dependencies = [ - "webpki", + "rustls-pki-types", ] -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - [[package]] name = "weezl" version = "0.1.8" @@ -4093,3 +4383,9 @@ dependencies = [ "quote", "syn 2.0.61", ] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/discord_bot/Cargo.toml b/discord_bot/Cargo.toml index 864e837..6972ab3 100644 --- a/discord_bot/Cargo.toml +++ b/discord_bot/Cargo.toml @@ -7,6 +7,6 @@ description = "Discord bot to provide rukaidata links" repository = "https://github.com/rukai/rukaidata" [dependencies] -serenity = { version = "=0.11.2", default-features=false, features = ["client", "gateway", "rustls_backend", "model", "unstable_discord_api"] } +poise = { version = "0.6.1" } time = "0.3.7" tokio = { version = "1.15", features = ["macros", "rt-multi-thread"] } diff --git a/discord_bot/src/main.rs b/discord_bot/src/main.rs index 5d4bed8..6d71912 100644 --- a/discord_bot/src/main.rs +++ b/discord_bot/src/main.rs @@ -5,20 +5,7 @@ pub mod characters; pub mod subactions; -use std::env; - -use serenity::async_trait; -use serenity::model::channel::Message; -use serenity::model::gateway::Ready; -use serenity::model::id::ChannelId; -use serenity::model::interactions::application_command::{ - ApplicationCommand, ApplicationCommandInteraction, - ApplicationCommandInteractionDataOptionValue, ApplicationCommandOptionType, -}; -use serenity::model::interactions::{ - Interaction, InteractionApplicationCommandCallbackDataFlags, InteractionResponseType, -}; -use serenity::prelude::*; +use poise::serenity_prelude as serenity; fn tokenize(msg: &str) -> Vec { let lower = msg.trim().to_lowercase(); @@ -29,55 +16,65 @@ fn timestamp() -> String { time::OffsetDateTime::now_utc().to_string() } -fn commands(command: &ApplicationCommandInteraction) -> Result { - match command.data.name.as_str() { - "rattening" => Ok("🐀🐀🐀 https://www.youtube.com/watch?v=qXEtmSi36AI".to_string()), - command_name => data_command(command_name, command), - } +struct Data {} // User data, which is stored and accessible in all command invocations +type Error = Box; +type Context<'a> = poise::Context<'a, Data, Error>; + +/// Commence the rattening! +#[poise::command(slash_command, prefix_command)] +async fn rattening(ctx: Context<'_>) -> Result<(), Error> { + ctx.say("🐀🐀🐀 https://www.youtube.com/watch?v=qXEtmSi36AI".to_string()) + .await?; + Ok(()) } -fn data_command( - command_name: &str, - command: &ApplicationCommandInteraction, -) -> Result { - let fighter_option = match command - .data - .options - .first() - .unwrap() - .resolved - .as_ref() - .unwrap() - { - ApplicationCommandInteractionDataOptionValue::String(value) => value, - data => { - return Err(format!("Unexpected fighter arg {:?}", data)); - } - }; - let subaction_option = match command - .data - .options - .get(1) - .unwrap() - .resolved - .as_ref() - .unwrap() - { - ApplicationCommandInteractionDataOptionValue::String(value) => value, - data => { - return Err(format!("Unexpected subaction arg {:?}", data)); - } - }; +/// Display Brawl frame data +#[poise::command(slash_command)] +async fn databrawl( + ctx: Context<'_>, + #[description = "The name of the fighter"] fighter: String, + #[description = "The name of the action"] action: String, +) -> Result<(), Error> { + data("Brawl", ctx, fighter, action).await +} - let mod_path = match command_name { - "databrawl" => "Brawl", - "datapm" => "PM3.6", - "datapplus" => "P+", - "datalxp" => "LXP2.1", - name => return Err(format!("Outdated slash command: {}", name)), - }; +/// Display Project+ (latest release) frame data +#[poise::command(slash_command)] +async fn datapplus( + ctx: Context<'_>, + #[description = "The name of the fighter"] fighter: String, + #[description = "The name of the action"] action: String, +) -> Result<(), Error> { + data("P+", ctx, fighter, action).await +} + +/// Display Legacy XP 2.1 frame data +#[poise::command(slash_command)] +async fn datalxp( + ctx: Context<'_>, + #[description = "The name of the fighter"] fighter: String, + #[description = "The name of the action"] action: String, +) -> Result<(), Error> { + data("LXP2.1", ctx, fighter, action).await +} + +/// Display Project M 3.6 frame data +#[poise::command(slash_command)] +async fn datapm( + ctx: Context<'_>, + #[description = "The name of the fighter"] fighter: String, + #[description = "The name of the action"] action: String, +) -> Result<(), Error> { + data("PM3.6", ctx, fighter, action).await +} - let fighter_tokens = tokenize(fighter_option); +async fn data( + mod_path: &str, + ctx: Context<'_>, + fighter: String, + subaction: String, +) -> Result<(), Error> { + let fighter_tokens = tokenize(&fighter); let fighter_tokens: Vec<_> = fighter_tokens.iter().map(|x| x.as_str()).collect(); let mut character = None; for token in &fighter_tokens { @@ -91,26 +88,26 @@ fn data_command( let character = match character { Some(character) => character, None => { - return Err(format!( - "fighter `{}` does not exist in mod `{}`", - fighter_option, mod_path - )) + return Err( + format!("fighter `{}` does not exist in mod `{}`", fighter, mod_path).into(), + ) } }; - let subaction_tokens = tokenize(subaction_option); + let subaction_tokens = tokenize(&subaction); let subaction_tokens: Vec<_> = subaction_tokens.iter().map(|x| x.as_str()).collect(); let subactions = subactions::subactions(&subaction_tokens, character); if subactions.is_empty() { return Err(format!( "action `{}` does not exist on fighter `{}` in mod `{}`", - subaction_option, fighter_option, mod_path - )); + subaction, fighter, mod_path + ) + .into()); } println!("slash command {}", timestamp()); - Ok(subactions + let output = subactions .iter() .map(|subaction| { format!( @@ -119,203 +116,33 @@ fn data_command( ) }) .collect::>() - .join("\n")) -} + .join("\n"); + ctx.say(output).await?; -async fn command_response( - ctx: &Context, - command: ApplicationCommandInteraction, - content: &str, - ephemeral: bool, -) { - let flags = if ephemeral { - InteractionApplicationCommandCallbackDataFlags::EPHEMERAL - } else { - InteractionApplicationCommandCallbackDataFlags::empty() - }; - - if let Err(why) = command - .create_interaction_response(&ctx.http, |response| { - response - .kind(InteractionResponseType::ChannelMessageWithSource) - .interaction_response_data(|message| message.content(content).flags(flags)) - }) - .await - { - println!("Cannot respond to slash command: {}", why); - } -} - -struct Handler; - -#[async_trait] -impl EventHandler for Handler { - async fn interaction_create(&self, ctx: Context, interaction: Interaction) { - if let Interaction::ApplicationCommand(command) = interaction { - match commands(&command) { - Ok(result) => command_response(&ctx, command, &result, false).await, - Err(error) => { - println!("{}", error); - command_response(&ctx, command, &error, true).await - } - }; - } - } - #[rustfmt::skip] - async fn message(&self, ctx: Context, msg: Message) { - if msg.author.name != "rukaidata" { - let lower = msg.content.trim().to_lowercase(); - let tokens: Vec<_> = lower.split_whitespace().collect(); - - if let Some(command) = tokens.first() { - if *command == ".brawldata" || *command == ".pm3.02data" || *command == ".pm3.6data" || *command == ".p+data" || *command == ".xpdata" || *command == ".lxpdata" || *command == ".lxp2.1data" - || *command == "!brawldata" || *command == "!pm3.02data" || *command == "!pm3.6data" || *command == "!p+data" || *command == "!xpdata" || *command == "!lxpdata" || *command == "!lxp2.1data" || *command == "!pmdata" - || *command == "!secretdata" || *command == ".secretdata" { - let mod_path = match command[1..].as_ref() { - "brawldata" => "Brawl", - "pmdata" => "PM3.6", - "pm3.6data" => "PM3.6", - "pm3.02data" => "PM3.02", - "p+data" => "P+", - "xpdata" => "LXP2.1", - "lxpdata" => "LXP2.1", - "lxp2.1data" => "LXP2.1", - "secretdata" => "Secret", - _ => unreachable!(), - }; - - let mut character = None; - for token in &tokens { - character = characters::character(mod_path, token); - - if character.is_some() { - break; - } - } - - let subactions = character.map(|x| subactions::subactions(&tokens, x)).unwrap_or_else(Vec::new); - - let message = match (character, subactions.is_empty()) { - (Some(character), false) => { - let mut message = String::new(); - for subaction in &subactions { - if !message.is_empty() { - message.push('\n'); - } - message.push_str(&format!("https://rukaidata.com/{}/{}/subactions/{}.html", mod_path, character, subaction)); - } - message - } - (Some(character), true ) => format!("https://rukaidata.com/{}/{}", mod_path, character), - (None, false) => "Need to specify a character.".to_string(), - (None, true ) => format!("https://rukaidata.com/{}", mod_path), - }; - - send(&ctx, &msg.channel_id, &message).await; - - println!("{}", timestamp()); - } - - if *command == ".rattening" || *command == "!rattening" { - send(&ctx, &msg.channel_id, "🐀🐀🐀 https://www.youtube.com/watch?v=qXEtmSi36AI").await; - } - } - } - } - - async fn ready(&self, ctx: Context, ready: Ready) { - let data_commands = [ - DataCommand { - name: "databrawl", - description: "Display Brawl frame data", - }, - DataCommand { - name: "datapm", - description: "Display Project M 3.6 frame data", - }, - DataCommand { - name: "datapplus", - description: "Display Project+ (latest release) frame data", - }, - DataCommand { - name: "datalxp", - description: "Display Legacy XP 2.1 frame data", - }, - ]; - for data_command in data_commands { - let command_result = - ApplicationCommand::create_global_application_command(&ctx.http, |command| { - command - .name(data_command.name) - .description(data_command.description) - .create_option(|option| { - option - .name("fighter") - .description("The name of the fighter") - .kind(ApplicationCommandOptionType::String) - .required(true) - }) - .create_option(|option| { - option - .name("action") - .description("The name of the action") - .kind(ApplicationCommandOptionType::String) - .required(true) - }) - }) - .await; - if let Err(err) = command_result { - println!( - "Failed to create global slash command for {}: {}", - data_command.name, err - ); - } - } - - let command_result = - ApplicationCommand::create_global_application_command(&ctx.http, |command| { - command - .name("rattening") - .description("Commence the rattening!") - }) - .await; - if let Err(err) = command_result { - println!( - "Failed to create global slash command for rattening: {}", - err - ); - } - println!("{} is connected!", ready.user.name); - } -} - -struct DataCommand { - name: &'static str, - description: &'static str, -} - -async fn send(ctx: &Context, channel_id: &ChannelId, text: &str) { - if let Err(why) = channel_id.say(&ctx.http, text).await { - println!("Error sending message: {:?}", why); - } + Ok(()) } #[tokio::main] async fn main() { - let discord_token = - env::var("DISCORD_TOKEN").expect("Expected DISCORD_TOKEN in the environment"); - let application_id = env::var("APPLICATION_ID") - .expect("Expected APPLICATION_ID in the environment") - .parse() - .expect("APPLICATION_ID must be numeric"); - - let mut client = Client::builder(&discord_token, GatewayIntents::default()) - .event_handler(Handler) - .application_id(application_id) - .await - .expect("Err creating client"); + let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN"); + let intents = serenity::GatewayIntents::non_privileged(); + let commands = vec![rattening(), databrawl(), datapplus(), datapm(), datalxp()]; + + let framework = poise::Framework::builder() + .options(poise::FrameworkOptions { + commands, + ..Default::default() + }) + .setup(|ctx, _ready, framework| { + Box::pin(async move { + poise::builtins::register_globally(ctx, &framework.options().commands).await?; + Ok(Data {}) + }) + }) + .build(); - if let Err(why) = client.start().await { - println!("Client error: {:?}", why); - } + let client = serenity::ClientBuilder::new(token, intents) + .framework(framework) + .await; + client.unwrap().start().await.unwrap(); }