html terminal
render schematics
bendn 2023-06-30
parent 3195ff4 · commit f912641
-rw-r--r--Cargo.lock354
-rw-r--r--Cargo.toml2
-rw-r--r--src/bot/mod.rs45
-rw-r--r--src/bot/schematic.rs90
-rw-r--r--src/main.rs2
5 files changed, 424 insertions, 69 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d912d5a..874aaa0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,6 +3,15 @@
version = 3
[[package]]
+name = "addr2line"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -72,7 +81,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
@@ -144,6 +153,21 @@ dependencies = [
]
[[package]]
+name = "backtrace"
+version = "0.3.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12"
+dependencies = [
+ "addr2line",
+ "cc",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
+
+[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -183,6 +207,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
+name = "bytemuck"
+version = "1.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
+
+[[package]]
name = "byteorder"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -199,6 +229,9 @@ name = "cc"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
+dependencies = [
+ "jobserver",
+]
[[package]]
name = "cfg-if"
@@ -220,6 +253,24 @@ dependencies = [
]
[[package]]
+name = "color-hex"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ecdffb913a326b6c642290a0d0ec8e8d6597291acdc07cc4c9cb4b3635d44cf9"
+
+[[package]]
+name = "color_quant"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
+
+[[package]]
+name = "const-str"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce5cd0d05ad8032f6252503d4a61401b640ce9365082accf046c68c7a419339d"
+
+[[package]]
name = "convert_case"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -259,6 +310,15 @@ dependencies = [
]
[[package]]
+name = "crossbeam-utils"
+version = "0.8.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -378,12 +438,22 @@ dependencies = [
]
[[package]]
+name = "fdeflate"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10"
+dependencies = [
+ "simd-adler32",
+]
+
+[[package]]
name = "flate2"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
dependencies = [
"crc32fast",
+ "libz-sys",
"miniz_oxide",
]
@@ -458,7 +528,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
@@ -513,10 +583,16 @@ dependencies = [
]
[[package]]
+name = "gimli"
+version = "0.27.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
+
+[[package]]
name = "h2"
-version = "0.3.19"
+version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782"
+checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049"
dependencies = [
"bytes",
"fnv",
@@ -549,12 +625,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
-version = "0.2.6"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
-dependencies = [
- "libc",
-]
+checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
[[package]]
name = "http"
@@ -592,9 +665,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
-version = "0.14.26"
+version = "0.14.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4"
+checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"
dependencies = [
"bytes",
"futures-channel",
@@ -667,6 +740,20 @@ dependencies = [
]
[[package]]
+name = "image"
+version = "0.24.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a"
+dependencies = [
+ "bytemuck",
+ "byteorder",
+ "color_quant",
+ "num-rational 0.4.1",
+ "num-traits",
+ "png",
+]
+
+[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -678,9 +765,9 @@ dependencies = [
[[package]]
name = "ipnet"
-version = "2.7.2"
+version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f"
+checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
[[package]]
name = "itertools"
@@ -698,6 +785,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
+name = "jobserver"
+version = "0.1.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "js-sys"
version = "0.3.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -714,9 +810,20 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.146"
+version = "0.2.147"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
+
+[[package]]
+name = "libz-sys"
+version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
+checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db"
+dependencies = [
+ "cc",
+ "pkg-config",
+ "vcpkg",
+]
[[package]]
name = "lock_api"
@@ -763,6 +870,23 @@ dependencies = [
]
[[package]]
+name = "mindus"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba4b5c6ed0672aed344fe06fd06490b2e091359c400d0affe68cacff4e34acdf"
+dependencies = [
+ "base64 0.21.2",
+ "color-hex",
+ "const-str",
+ "flate2",
+ "image",
+ "paste",
+ "strconv",
+ "walkdir",
+ "zip",
+]
+
+[[package]]
name = "minify-html"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -809,6 +933,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
+ "simd-adler32",
]
[[package]]
@@ -842,7 +967,7 @@ dependencies = [
"num-complex",
"num-integer",
"num-iter",
- "num-rational",
+ "num-rational 0.2.4",
"num-traits",
]
@@ -901,6 +1026,17 @@ dependencies = [
]
[[package]]
+name = "num-rational"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
+dependencies = [
+ "autocfg",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -911,15 +1047,24 @@ dependencies = [
[[package]]
name = "num_cpus"
-version = "1.15.0"
+version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
+checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
+name = "object"
+version = "0.31.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
name = "once_cell"
version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -944,7 +1089,9 @@ dependencies = [
"convert_case 0.6.0",
"futures",
"futures-util",
+ "image",
"itertools",
+ "mindus",
"minify-html",
"minify-js 0.5.6",
"parse_duration",
@@ -1031,22 +1178,22 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
[[package]]
name = "pin-project"
-version = "1.1.0"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead"
+checksum = "6e138fdd8263907a2b0e1b4e80b7e58c721126479b6e6eedfb1b402acea7b9bd"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
-version = "1.1.0"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07"
+checksum = "d1fef411b303e3e12d534fb6e7852de82da56edd937d895125821fb7c09436c7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
@@ -1062,6 +1209,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
+name = "pkg-config"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
+
+[[package]]
+name = "png"
+version = "0.17.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11"
+dependencies = [
+ "bitflags",
+ "crc32fast",
+ "fdeflate",
+ "flate2",
+ "miniz_oxide",
+]
+
+[[package]]
name = "poise"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1100,18 +1266,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro2"
-version = "1.0.60"
+version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
+checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.28"
+version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
+checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
dependencies = [
"proc-macro2",
]
@@ -1230,6 +1396,12 @@ dependencies = [
]
[[package]]
+name = "rustc-demangle"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
+
+[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1270,9 +1442,9 @@ dependencies = [
[[package]]
name = "rustls-pemfile"
-version = "1.0.2"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b"
+checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2"
dependencies = [
"base64 0.21.2",
]
@@ -1300,6 +1472,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1348,14 +1529,14 @@ checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
name = "serde_json"
-version = "1.0.97"
+version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bdf3bf93142acad5821c99197022e170842cdbc1c30482b98750c688c640842a"
+checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3"
dependencies = [
"itoa",
"ryu",
@@ -1418,6 +1599,12 @@ dependencies = [
]
[[package]]
+name = "simd-adler32"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f"
+
+[[package]]
name = "slab"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1449,6 +1636,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
+name = "strconv"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f32df10f08eec2c31bc4e24768cef452df8f7c44c40f3c92c268a1c61195f8c4"
+dependencies = [
+ "syn 2.0.22",
+]
+
+[[package]]
name = "strip-ansi-escapes"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1476,9 +1672,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.18"
+version = "2.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e"
+checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616"
dependencies = [
"proc-macro2",
"quote",
@@ -1508,7 +1704,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
@@ -1555,11 +1751,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.28.2"
+version = "1.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2"
+checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da"
dependencies = [
"autocfg",
+ "backtrace",
"bytes",
"libc",
"mio",
@@ -1579,7 +1776,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
@@ -1670,13 +1867,13 @@ dependencies = [
[[package]]
name = "tracing-attributes"
-version = "0.1.25"
+version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8803eee176538f94ae9a14b55b2804eb7e1441f8210b1c31290b3bccdccff73b"
+checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
]
[[package]]
@@ -1794,6 +1991,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1821,6 +2024,16 @@ dependencies = [
]
[[package]]
+name = "walkdir"
+version = "2.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
name = "want"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1856,7 +2069,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
"wasm-bindgen-shared",
]
@@ -1890,7 +2103,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.22",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -1960,6 +2173,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1985,9 +2207,9 @@ dependencies = [
[[package]]
name = "windows-targets"
-version = "0.48.0"
+version = "0.48.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
+checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@@ -2048,3 +2270,45 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
dependencies = [
"winapi",
]
+
+[[package]]
+name = "zip"
+version = "0.6.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
+dependencies = [
+ "byteorder",
+ "crc32fast",
+ "crossbeam-utils",
+ "zstd",
+]
+
+[[package]]
+name = "zstd"
+version = "0.11.2+zstd.1.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
+dependencies = [
+ "zstd-safe",
+]
+
+[[package]]
+name = "zstd-safe"
+version = "5.0.2+zstd.1.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
+dependencies = [
+ "libc",
+ "zstd-sys",
+]
+
+[[package]]
+name = "zstd-sys"
+version = "2.0.8+zstd.1.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+]
diff --git a/Cargo.toml b/Cargo.toml
index de8ad26..ffe2231 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,6 +40,8 @@ parse_duration = "2.1.1"
serde = "1.0"
serde_json = "1.0"
btparse = "0.1.1"
+mindus = "1.0"
+image = { version = "0.24.6", features = ["png"], default-features = false }
[profile.release]
lto = true
diff --git a/src/bot/mod.rs b/src/bot/mod.rs
index a559dee..fb5a2ec 100644
--- a/src/bot/mod.rs
+++ b/src/bot/mod.rs
@@ -4,6 +4,7 @@ mod config;
mod js;
mod maps;
mod player;
+mod schematic;
mod status;
mod voting;
@@ -14,6 +15,7 @@ use maps::Maps;
use serenity::http::Http;
use serenity::prelude::*;
use std::fs::read_to_string;
+use std::str::FromStr;
use std::sync::{Arc, Mutex, OnceLock};
use tokio::sync::broadcast;
@@ -69,6 +71,8 @@ impl Bot {
voting::create(),
voting::fixall(),
voting::list(),
+ schematic::draw(),
+ schematic::context_draw(),
start(),
end(),
help(),
@@ -114,28 +118,26 @@ async fn on_error(error: poise::FrameworkError<'_, Data, anyhow::Error>) {
match error {
Command { error, ctx } => {
ctx.say(format!("e: `{error}`")).await.unwrap();
- if let Ok(n) = std::env::var("RUST_LIB_BACKTRACE") {
- use std::str::FromStr;
- if let Ok(n) = u8::from_str(&n) {
- if n == 1 {
- let mut parsed = btparse::deserialize(dbg!(error.backtrace())).unwrap();
- let mut s = vec![];
- for frame in &mut parsed.frames {
- if let Some(line) = frame.line.take() {
- if frame.function.contains("panel")
- || frame.function.contains("poise")
- || frame.function.contains("serenity")
- {
- s.push(format!("l{}@{}", line, frame.function));
- }
+ if let Ok(n) = std::env::var("RUST_LIB_BACKTRACE")
+ && let Ok(n) = u8::from_str(&n)
+ && n == 1 {
+ let mut parsed = btparse::deserialize(dbg!(error.backtrace())).unwrap();
+ let mut s = vec![];
+ for frame in &mut parsed.frames {
+ if let Some(line) = frame.line.take()
+ && (frame.function.contains("panel")
+ || frame.function.contains("poise")
+ || frame.function.contains("serenity"))
+ {
+ s.push(format!("l{}@{}", line, frame.function));
}
- }
- s.truncate(15);
- ctx.say(format!("trace: ```rs\n{}\n```", s.join("\n")))
- .await
- .unwrap();
+
}
- }
+ s.truncate(15);
+ ctx.say(format!("trace: ```rs\n{}\n```", s.join("\n")))
+ .await
+ .unwrap();
+
}
}
err => poise::builtins::on_error(err).await.unwrap(),
@@ -183,7 +185,6 @@ async fn get_nextblock() -> String {
#[poise::command(slash_command, category = "Control")]
/// say something as the server
async fn say(ctx: Context<'_>, #[description = "Message"] message: String) -> Result<()> {
- let _ = ctx.defer().await;
ctx.data().stdin.send(format!("say {message}"))?;
return_next!(ctx)
}
@@ -216,7 +217,6 @@ pub async fn start(
#[autocomplete = "maps::autocomplete"]
map: String,
) -> Result<()> {
- let _ = ctx.defer().await;
send_ctx!(ctx, "host {}", Maps::find(&map, &ctx.data().stdin).await)?;
return_next!(ctx)
}
@@ -233,7 +233,6 @@ pub async fn end(
#[autocomplete = "maps::autocomplete"]
map: String,
) -> Result<()> {
- let _ = ctx.defer().await;
send_ctx!(
ctx,
"gameover {}",
diff --git a/src/bot/schematic.rs b/src/bot/schematic.rs
new file mode 100644
index 0000000..0b05f1f
--- /dev/null
+++ b/src/bot/schematic.rs
@@ -0,0 +1,90 @@
+use super::{strip_colors, Context, SUCCESS};
+use anyhow::{anyhow, Result};
+use image::{codecs::png::PngEncoder, ImageEncoder};
+use mindus::data::schematic::R64Error;
+use mindus::data::{DataRead, Serializer};
+use mindus::*;
+use poise::serenity_prelude::*;
+use regex::Regex;
+use std::borrow::Cow;
+use std::path::Path;
+use std::sync::LazyLock;
+
+static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"(```)?([^`]+)(```)?"#).unwrap());
+static REG: LazyLock<mindus::block::BlockRegistry> = LazyLock::new(build_registry);
+
+#[poise::command(context_menu_command = "Render schematic", category = "Info")]
+/// server status.
+pub async fn context_draw(ctx: Context<'_>, msg: Message) -> Result<()> {
+ let _ = ctx.defer_or_broadcast().await;
+
+ if let Some(a) = msg.attachments.get(0)
+ && let Some(e) = Path::new(&a.filename).extension()
+ && e == "msch" {
+ let mut ss = SchematicSerializer(&REG);
+ let s = a.download().await?;
+ let mut s = DataRead::new(&s);
+ let Ok(s) = ss.deserialize(&mut s) else {
+ ctx.say(format!("invalid schematic ({})", a.filename)).await?;
+ return Ok(());
+ };
+ return send(&ctx, &s).await;
+ }
+ draw_impl(ctx, &msg.content).await
+}
+
+#[poise::command(
+ prefix_command,
+ slash_command,
+ category = "Info",
+ rename = "draw_schematic"
+)]
+/// server status.
+pub async fn draw(ctx: Context<'_>, schematic: String) -> Result<()> {
+ let _ = ctx.defer_or_broadcast().await;
+ draw_impl(ctx, &schematic).await
+}
+
+async fn send(ctx: &Context<'_>, s: &Schematic<'_>) -> Result<()> {
+ let mut b = vec![];
+ let p = Renderer::render(s);
+ PngEncoder::new(&mut b).write_image(&p, p.width(), p.height(), image::ColorType::Rgba8)?;
+ let n = strip_colors(s.tags.get("name").unwrap());
+ let filename = "image.png";
+ poise::send_reply(*ctx, |m| {
+ m.attachment(AttachmentType::Bytes {
+ data: Cow::Owned(b),
+ filename: filename.to_string(),
+ })
+ .embed(|e| {
+ if let Some(d) = s.tags.get("description") {
+ e.description(d);
+ }
+ e.title(n).attachment(filename).color(SUCCESS)
+ })
+ })
+ .await?;
+ return Ok(());
+}
+
+async fn draw_impl(ctx: Context<'_>, msg: &str) -> Result<()> {
+ let mut ss = SchematicSerializer(&REG);
+ let schem_text = RE
+ .captures(msg)
+ .ok_or(anyhow!("couldnt find schematic"))?
+ .get(2)
+ .unwrap()
+ .as_str();
+ let s = match ss.deserialize_base64(schem_text) {
+ Err(e) => {
+ ctx.say(match e {
+ R64Error::Base64(_) => "invalid base64",
+ R64Error::Content(_) => "invalid schematic",
+ })
+ .await?;
+ return Ok(());
+ }
+ Ok(x) => x,
+ };
+ send(&ctx, &s).await
+}
diff --git a/src/main.rs b/src/main.rs
index 1a7a9dd..3f002ee 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-#![feature(lazy_cell)]
+#![feature(lazy_cell, let_chains)]
use std::str::FromStr;
#[macro_use]
mod logging;