From 46d52af4fd6f30d8a46ea3d0c0c2590374ceb951 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Tue, 3 Mar 2026 19:42:07 -0600 Subject: [PATCH 01/10] Implement justfile --- README.md | 4 ++-- justfile | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 justfile diff --git a/README.md b/README.md index fd96985..1592be3 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Bot de la comunidad de Discord de RustLang en Español. Las variables de entorno necesarias están documentadas en [`doc/VARIABLES.md`](doc/VARIABLES.md). Asegúrate de configurarlas antes de ejecutar el bot. -[!NOTE] -Pequeño disclaimer: Para que el cangrebot funcione correctamente, el bot debe tener permisos de administrador en el servidor de Discord. +> [!WARNING] +> Pequeño disclaimer: Para que el cangrebot funcione correctamente, el bot debe tener permisos de administrador en el servidor de Discord. ### 2. Gestión de Submódulos diff --git a/justfile b/justfile new file mode 100644 index 0000000..2cb0c5e --- /dev/null +++ b/justfile @@ -0,0 +1,13 @@ +default: check build clippy test + +check: + cargo fmt --all --check + +build: + cargo build + +test: + cargo test --verbose + +clippy: + cargo clippy --all-targets --all-features -- -D warnings \ No newline at end of file From 63ae178e093a2c01a5731694df8fedb035623f17 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Tue, 3 Mar 2026 19:53:51 -0600 Subject: [PATCH 02/10] Implement ci only in pull request that is not draft --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7367dd1..37bfac1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,8 @@ on: workflow_dispatch: workflow_call: pull_request: + types: + - ready_for_review push: branches: - main From 8eb65e216516b469be477da3a68efec7684c5d10 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Tue, 3 Mar 2026 20:03:37 -0600 Subject: [PATCH 03/10] Modify the stages in ci and justfile --- .github/workflows/ci.yml | 9 ++++++++- justfile | 14 ++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37bfac1..a01c8a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,4 +34,11 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Checks run: | - cargo clippy -- -D warnings + cargo clippy --all-targets --all-features -- -D warnings + + test: + needs: [check-clippy] + runs-on: ubuntu-22.04 + steps: + - name: Test + run: cargo test --verbose diff --git a/justfile b/justfile index 2cb0c5e..0f78e81 100644 --- a/justfile +++ b/justfile @@ -1,13 +1,11 @@ -default: check build clippy test +default: test -check: +check-fmt: cargo fmt --all --check + +clippy: check-fmt + cargo clippy --all-targets --all-features -- -D warnings -build: - cargo build - -test: +test: clippy cargo test --verbose -clippy: - cargo clippy --all-targets --all-features -- -D warnings \ No newline at end of file From 507fbd29b3fa3d72bf977f9f5bc4ba9564e93011 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Wed, 4 Mar 2026 20:37:50 -0600 Subject: [PATCH 04/10] Implement handle for unique word or sentence < 16 charaters --- Cargo.lock | 960 +++++++++++++++++++++++++++++- Cargo.toml | 14 +- README.md | 1 + src/bot/commands/tts/mod.rs | 30 +- src/bot/commands/tts/tts_regex.rs | 5 +- 5 files changed, 971 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7730ee9..30178ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,6 +236,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.21.7" @@ -248,6 +254,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + [[package]] name = "bitflags" version = "1.3.2" @@ -473,6 +485,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "conv" version = "0.3.3" @@ -514,6 +532,17 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core-models" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94950e87ea550d6d68f1993f3e7bebc8cb7235157bff84337d46195c3aa0b3f0" +dependencies = [ + "hax-lib", + "pastey", + "rand 0.9.2", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -541,12 +570,43 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -590,6 +650,33 @@ dependencies = [ "cipher", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "custom_derive" version = "0.1.7" @@ -676,7 +763,7 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core", + "parking_lot_core 0.9.11", "serde", ] @@ -691,7 +778,7 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core", + "parking_lot_core 0.9.11", ] [[package]] @@ -700,6 +787,44 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" +[[package]] +name = "davey" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20e05bae3e741c249912d39c6cec28d2ef3c1a196e9acac025582182a8f9fbb7" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "hex-literal", + "hmac", + "num-derive", + "num-traits", + "openmls", + "openmls_basic_credential", + "openmls_rust_crypto", + "p256", + "rand 0.8.5", + "scrypt", + "sha2", + "subtle", + "thiserror 2.0.12", + "tracing", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.4.0" @@ -766,7 +891,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -811,6 +938,45 @@ dependencies = [ "dtoa", ] +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand_core 0.6.4", + "serde", + "sha2", + "subtle", + "zeroize", +] + [[package]] name = "ego-tree" version = "0.6.3" @@ -823,6 +989,27 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "hkdf", + "pem-rfc7468", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encoding_rs" version = "0.8.35" @@ -888,6 +1075,22 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "flate2" version = "1.1.2" @@ -910,6 +1113,21 @@ dependencies = [ "spin", ] +[[package]] +name = "fluvio-wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b768c170dc045fa587a8f948c91f9bcfb87f774930477c6215addf54317f137f" +dependencies = [ + "futures", + "js-sys", + "parking_lot 0.11.2", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1072,6 +1290,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -1132,6 +1351,17 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "h2" version = "0.3.27" @@ -1174,6 +1404,43 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "hax-lib" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "543f93241d32b3f00569201bfce9d7a93c92c6421b23c77864ac929dc947b9fc" +dependencies = [ + "hax-lib-macros", + "num-bigint", + "num-traits", +] + +[[package]] +name = "hax-lib-macros" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8755751e760b11021765bb04cb4a6c4e24742688d9f3aa14c2079638f537b0f" +dependencies = [ + "hax-lib-macros-types", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "hax-lib-macros-types" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f177c9ae8ea456e2f71ff3c1ea47bf4464f772a05133fcbba56cd5ba169035a2" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_json", + "uuid", +] + [[package]] name = "heck" version = "0.3.3" @@ -1195,6 +1462,21 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + [[package]] name = "hls_m3u8" version = "0.4.2" @@ -1210,6 +1492,77 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "hpke-rs" +version = "0.3.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b245758dea58531acbdd0e9a20d73a93561a78f78531a2bed0ef9b5a39cc0ff2" +dependencies = [ + "hpke-rs-crypto", + "hpke-rs-libcrux", + "hpke-rs-rust-crypto", + "libcrux-sha3", + "log", + "rand_core 0.9.3", + "serde", + "tls_codec", + "zeroize", +] + +[[package]] +name = "hpke-rs-crypto" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51ffd304e06803f90f2e56a24a6910f19b8516f842d7b72a436c51026279876" +dependencies = [ + "rand_core 0.9.3", +] + +[[package]] +name = "hpke-rs-libcrux" +version = "0.3.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96fa708a147e2068a04ec209f5d94f2446f89a754e2556a4c14b88101aa26ff8" +dependencies = [ + "hpke-rs-crypto", + "libcrux-chacha20poly1305", + "libcrux-ecdh", + "libcrux-hkdf", + "libcrux-kem", + "rand 0.9.2", + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "hpke-rs-rust-crypto" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff7dc0df494528a0b90005bb511c117453c6a89cd8819f6cf311d0f4446dcf45" +dependencies = [ + "aes-gcm", + "chacha20poly1305", + "hkdf", + "hpke-rs-crypto", + "k256", + "p256", + "p384", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "sha2", + "x25519-dalek", +] + [[package]] name = "html5ever" version = "0.27.0" @@ -1594,6 +1947,18 @@ dependencies = [ "generic-array", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "io-uring" version = "0.7.9" @@ -1647,16 +2012,205 @@ dependencies = [ ] [[package]] -name = "lazy_static" -version = "1.5.0" +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "elliptic-curve", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "libcrux-chacha20poly1305" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0683aedd9048bead90863fa83f56fc224ea545762fdd108c845d5c15391413" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-macros", + "libcrux-poly1305", +] + +[[package]] +name = "libcrux-curve25519" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a39960483f24efea15b1aa111bb8668dc671f808598793104ccc4fec9f5e28b" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-macros", +] + +[[package]] +name = "libcrux-ecdh" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5ecef729c99bb2f751133b89186a636cd8b3e8320d094131d21ea8c82348ca" +dependencies = [ + "libcrux-curve25519", + "libcrux-p256", + "rand 0.9.2", +] + +[[package]] +name = "libcrux-hacl-rs" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a141e79dcefa1a91b68831783114232ed6a69b8c8c853c6e6b1cf2af231c3c" +dependencies = [ + "libcrux-macros", +] + +[[package]] +name = "libcrux-hkdf" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2663b258d1a4a023a03e946bb949cf30f862d2da1e68fe9a1d3e6103c1d4a6a5" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-hmac", +] + +[[package]] +name = "libcrux-hmac" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c8d021153affaad2aba7c6dd4c23e7304e77198080ce9b949c725682912154" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-macros", + "libcrux-sha2", +] + +[[package]] +name = "libcrux-intrinsics" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d3b41dcbc21a5fb7efbbb5af7405b2e79c4bfe443924e90b13afc0080318d31" +dependencies = [ + "core-models", + "hax-lib", +] + +[[package]] +name = "libcrux-kem" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc932402ccd803c064e228ff2a4d2aef5b5a0b03b461518d29046e01ebc2cf98" +dependencies = [ + "libcrux-ecdh", + "libcrux-ml-kem", + "libcrux-sha3", + "libcrux-traits", + "rand 0.9.2", +] + +[[package]] +name = "libcrux-macros" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc8e38ec9c49ba83cb7e72d278c3537552afbc67728f22e567c21725cdd8b3ba" +dependencies = [ + "quote", + "syn 2.0.104", +] + +[[package]] +name = "libcrux-ml-kem" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6206bb81fc3e51bd94d4b847760039d44a9a8e77bac841df8ed9320f79a6f3be" +dependencies = [ + "hax-lib", + "libcrux-intrinsics", + "libcrux-platform", + "libcrux-secrets", + "libcrux-sha3", + "rand 0.9.2", +] + +[[package]] +name = "libcrux-p256" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb56de31fa136bdaa838401547c3644f3e11c7929818dfb45d934a2db7ab521" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-macros", + "libcrux-sha2", +] + +[[package]] +name = "libcrux-platform" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db82d058aa76ea315a3b2092f69dfbd67ddb0e462038a206e1dcd73f058c0778" +dependencies = [ + "libc", +] + +[[package]] +name = "libcrux-poly1305" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8907194cd2d35dd763519189036c6062f5464ac9b63fb968b10abcb09feef3" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-macros", +] + +[[package]] +name = "libcrux-secrets" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332737e629fe6ba7547f5c0f90559eac865d5dbecf98138ffae8f16ab8cbe33f" +dependencies = [ + "hax-lib", +] + +[[package]] +name = "libcrux-sha2" +version = "0.0.3-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0c0266cc2b0920f3b1540bb1268ea5dae2cfff9aa0e92b316d2c73e618fb64" +dependencies = [ + "libcrux-hacl-rs", + "libcrux-macros", + "libcrux-traits", +] + +[[package]] +name = "libcrux-sha3" +version = "0.0.3-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "84c076a07a2df2cc8f6603042823e752c0057bce51beb4e0b2cbf0b3dfb7f73d" +dependencies = [ + "hax-lib", + "libcrux-intrinsics", + "libcrux-platform", +] [[package]] -name = "libc" -version = "0.2.174" +name = "libcrux-traits" +version = "0.0.3-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +checksum = "477d39395a82293e079313c288f313bcbb62501ae4c31588e471344eea1a77da" +dependencies = [ + "rand 0.9.2", +] [[package]] name = "libm" @@ -1913,6 +2467,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -1985,6 +2550,86 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openmls" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692e9c6b7d725e53cc42d1fa870066770fd67df35cf1cfbbd047dc0355e06b67" +dependencies = [ + "fluvio-wasm-timer", + "getrandom 0.2.16", + "log", + "openmls_traits", + "rayon", + "serde", + "serde_bytes", + "thiserror 2.0.12", + "tls_codec", + "zeroize", +] + +[[package]] +name = "openmls_basic_credential" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e6454b2b1b6749fc2f142d7f74eb387f7793be88187ed372e9f5f4cf10c34c" +dependencies = [ + "ed25519-dalek", + "openmls_traits", + "p256", + "rand 0.8.5", + "serde", + "tls_codec", +] + +[[package]] +name = "openmls_memory_storage" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e7b071ea5573a97efaa72b7c53e81cebc644b62ef0fe992bad685cc0f7dd4ea" +dependencies = [ + "log", + "openmls_traits", + "serde", + "serde_json", + "thiserror 2.0.12", +] + +[[package]] +name = "openmls_rust_crypto" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3faef09e17a15c8065b9ec6b1e150c19dcb0c4cb810a636b6f010a94a189678e" +dependencies = [ + "aes-gcm", + "chacha20poly1305", + "ed25519-dalek", + "hkdf", + "hmac", + "hpke-rs", + "hpke-rs-crypto", + "hpke-rs-rust-crypto", + "openmls_memory_storage", + "openmls_traits", + "p256", + "rand 0.8.5", + "rand_chacha 0.3.1", + "serde", + "sha2", + "thiserror 2.0.12", + "tls_codec", +] + +[[package]] +name = "openmls_traits" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e21d8877bacdbc407060df29bf59b145bb886a8fa0099b87ae8067a34b902a13" +dependencies = [ + "serde", + "tls_codec", +] + [[package]] name = "openssl-probe" version = "0.1.6" @@ -2021,6 +2666,39 @@ version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "p384" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe42f1670a52a47d448f14b6a5c61dd78fce51856e68edaa38f7ae3a46b8d6b6" +dependencies = [ + "elliptic-curve", + "primeorder", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.4" @@ -2028,7 +2706,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.11", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", ] [[package]] @@ -2039,7 +2731,7 @@ checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.17", "smallvec", "windows-targets 0.52.6", ] @@ -2050,6 +2742,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pastey" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" + [[package]] name = "patricia_tree" version = "0.8.0" @@ -2059,6 +2757,25 @@ dependencies = [ "bitflags 2.9.1", ] +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2187,6 +2904,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.32" @@ -2245,7 +2972,7 @@ dependencies = [ "async-trait", "derivative", "futures-util", - "parking_lot", + "parking_lot 0.12.4", "poise_macros", "regex", "serenity", @@ -2342,6 +3069,37 @@ dependencies = [ "num-integer", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "proc-macro2" version = "1.0.95" @@ -2513,6 +3271,26 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "realfft" version = "3.5.0" @@ -2522,6 +3300,15 @@ dependencies = [ "rustfft", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.17" @@ -2660,6 +3447,16 @@ dependencies = [ "webpki-roots 1.0.2", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ring" version = "0.17.14" @@ -2882,6 +3679,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + [[package]] name = "same-file" version = "1.0.6" @@ -2929,6 +3735,17 @@ dependencies = [ "tendril", ] +[[package]] +name = "scrypt" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f" +dependencies = [ + "pbkdf2", + "salsa20", + "sha2", +] + [[package]] name = "sct" version = "0.7.1" @@ -2939,6 +3756,20 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "secrecy" version = "0.8.0" @@ -3031,6 +3862,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_bytes" +version = "0.11.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" +dependencies = [ + "serde", +] + [[package]] name = "serde_cow" version = "0.1.2" @@ -3113,7 +3953,7 @@ dependencies = [ "futures", "fxhash", "mime_guess", - "parking_lot", + "parking_lot 0.12.4", "percent-encoding", "reqwest 0.11.27", "secrecy", @@ -3131,9 +3971,8 @@ dependencies = [ [[package]] name = "serenity-voice-model" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "593682f6155d07c8b331b3d1060f5aab7e6796caca9f2f66bd9e6855c880e06b" +version = "0.2.1" +source = "git+https://github.com/serenity-rs/voice-model.git?branch=next#b1400a1272da4ed259314133b2536006de1850ab" dependencies = [ "bitflags 2.9.1", "num-traits", @@ -3168,6 +4007,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -3204,6 +4054,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + [[package]] name = "simba" version = "0.8.1" @@ -3291,8 +4151,7 @@ dependencies = [ [[package]] name = "songbird" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0f2c269821881c25c6daa6863a611a10c9b40ed9f56e2955793bf06fb0fdfd" +source = "git+https://github.com/beerpsi-forks/songbird.git?branch=davey#25195877c715e08df25eda668df6b3a6bb3d3cdf" dependencies = [ "aead", "aes-gcm", @@ -3303,13 +4162,14 @@ dependencies = [ "chacha20poly1305", "crypto-common", "dashmap 6.1.0", + "davey", "derivative", "discortp", "either", "flume", "futures", "nohash-hasher", - "parking_lot", + "parking_lot 0.12.4", "pin-project", "rand 0.9.2", "reqwest 0.12.22", @@ -3347,6 +4207,16 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable-vec" version = "0.4.1" @@ -3403,7 +4273,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" dependencies = [ "new_debug_unreachable", - "parking_lot", + "parking_lot 0.12.4", "phf_shared 0.11.3", "precomputed-hash", "serde", @@ -3810,6 +4680,28 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tls_codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de2e01245e2bb89d6f05801c564fa27624dbd7b1846859876c7dad82e90bf6b" +dependencies = [ + "serde", + "tls_codec_derive", + "zeroize", +] + +[[package]] +name = "tls_codec_derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2e76690929402faae40aebdda620a2c0e25dd6d3b9afe48867dfd95991f4bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "tokio" version = "1.47.1" @@ -3821,7 +4713,7 @@ dependencies = [ "io-uring", "libc", "mio", - "parking_lot", + "parking_lot 0.12.4", "pin-project-lite", "signal-hook-registry", "slab", @@ -4211,7 +5103,7 @@ dependencies = [ "dashmap 5.5.3", "hashbrown 0.14.5", "mini-moka", - "parking_lot", + "parking_lot 0.12.4", "secrecy", "serde_json", "time", @@ -4841,6 +5733,18 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core 0.6.4", + "serde", + "zeroize", +] + [[package]] name = "yoke" version = "0.8.0" @@ -4911,6 +5815,20 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85a5b4158499876c763cb03bc4e49185d3cccbabb15b33c627f7884f43db852e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] [[package]] name = "zerotrie" diff --git a/Cargo.toml b/Cargo.toml index 87a9787..0eb882b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,12 +39,12 @@ urlencoding = "2.1.3" tracing-subscriber = { version = "0.3", features = ["env-filter"] } symphonia = { version = "0.5", features = ["mp3"] } -songbird = { version = "0.5", default-features = false, features = [ - "serenity", - "gateway", - "driver", - "tungstenite", - "rustls", - "builtin-queue", +songbird = { git = "https://github.com/beerpsi-forks/songbird.git", branch="davey", default-features = false, features = [ + "serenity", + "gateway", + "driver", + "tungstenite", + "rustls", + "builtin-queue", ] } uuid = { version = "1", features = ["v4"] } diff --git a/README.md b/README.md index 1592be3..a81a470 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Bot de la comunidad de Discord de RustLang en Español. Las variables de entorno necesarias están documentadas en [`doc/VARIABLES.md`](doc/VARIABLES.md). Asegúrate de configurarlas antes de ejecutar el bot. > [!WARNING] +> > Pequeño disclaimer: Para que el cangrebot funcione correctamente, el bot debe tener permisos de administrador en el servidor de Discord. ### 2. Gestión de Submódulos diff --git a/src/bot/commands/tts/mod.rs b/src/bot/commands/tts/mod.rs index 85f0980..1f8936d 100644 --- a/src/bot/commands/tts/mod.rs +++ b/src/bot/commands/tts/mod.rs @@ -36,6 +36,8 @@ macro_rules! replace_patterns { $({ static REGEX: LazyLock = LazyLock::new(|| Regex::new($re).expect("valid regex")); result = REGEX.replace_all(&result, |$caps: &Captures| -> Cow { + #[allow(unused_variables)] + let $caps = $caps; $body }).into_owned(); })* @@ -295,21 +297,31 @@ impl TtsState { ) -> Result<(), bot::Error> { let resolved = replace_mentions(guild_id, http.clone(), raw_text).await?; + fn handle_code_block(caps: &Captures) -> Cow<'static, str> { + let content = caps.get(1).map(|m| m.as_str().trim()).unwrap_or(""); + let word_count = content.chars().count(); + + if !content.is_empty() && word_count <= 16 { + Cow::Owned(content.to_string()) + } else { + Cow::Borrowed("Mira el bloque de código") + } + } + let cleaned = replace_patterns!( resolved, [ - (LINK_REGEX, |_caps| Cow::Borrowed("Enlace")), + (LINK_REGEX, |caps| Cow::Borrowed("Enlace")), (EMOJI_REGEX, |caps| Cow::Owned(caps[1].to_string())), (LAUGHTER_REGEX, |_caps| Cow::Borrowed("* Risa *")), - (WHAT_REGEX, |_caps| Cow::Borrowed("Que")), - (WHY_REGEX, |_caps| Cow::Borrowed("Por que")), + (WHAT_REGEX, |_caps| Cow::Borrowed("Qué")), + (WHY_REGEX, |_caps| Cow::Borrowed("Por qué")), (ALSO_REGEX, |_caps| Cow::Borrowed("También")), - (MULTI_LINE_CODE_BLOCK_REGEX, |caps| Cow::Borrowed( - "Mira el bloque de codigo" - )), - (INLINE_CODE_BLOCK_REGEX, |caps| Cow::Borrowed( - "Mira el bloque de codigo" - )), + (MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, + |caps| handle_code_block(caps)), + (MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, + |caps| handle_code_block(caps)), + (INLINE_CODE_BLOCK_REGEX, |caps| handle_code_block(caps)), (CORRECTION_REGEX, |caps| { let mut word_correction = caps[0].to_string(); word_correction.pop(); diff --git a/src/bot/commands/tts/tts_regex.rs b/src/bot/commands/tts/tts_regex.rs index 50427bc..487a0c2 100644 --- a/src/bot/commands/tts/tts_regex.rs +++ b/src/bot/commands/tts/tts_regex.rs @@ -5,6 +5,7 @@ pub const LAUGHTER_REGEX: &str = r"(?i)\b[jsadkf]{4,}\b"; pub const WHAT_REGEX: &str = r"(?i)\bq\b"; pub const WHY_REGEX: &str = r"(?i)\bxq\b"; pub const ALSO_REGEX: &str = r"(?i)\btmb\b"; -pub const INLINE_CODE_BLOCK_REGEX: &str = r"`[^`\n]*`"; -pub const MULTI_LINE_CODE_BLOCK_REGEX: &str = r"```[\s\S]*?```"; +pub const INLINE_CODE_BLOCK_REGEX: &str = r"`([^`\n]*)`"; +pub const MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX: &str = r"``([^`]+)``"; +pub const MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX: &str = r"```([\s\S]*?)```"; pub const CORRECTION_REGEX: &str = r"^\w+\*$"; From 53be76cbbb2c9b96898e108d5a0e7bcafd94f98b Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Thu, 5 Mar 2026 02:03:50 -0600 Subject: [PATCH 05/10] Implement test for tts code blocks --- src/bot/commands/tts/mod.rs | 12 +++-- src/bot/commands/tts/tts.rs | 75 +++++++++++++++++++++++++++++++ src/bot/commands/tts/tts_regex.rs | 4 +- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/bot/commands/tts/mod.rs b/src/bot/commands/tts/mod.rs index 1f8936d..665d8cc 100644 --- a/src/bot/commands/tts/mod.rs +++ b/src/bot/commands/tts/mod.rs @@ -317,10 +317,14 @@ impl TtsState { (WHAT_REGEX, |_caps| Cow::Borrowed("Qué")), (WHY_REGEX, |_caps| Cow::Borrowed("Por qué")), (ALSO_REGEX, |_caps| Cow::Borrowed("También")), - (MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, - |caps| handle_code_block(caps)), - (MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, - |caps| handle_code_block(caps)), + ( + MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, + |caps| handle_code_block(caps) + ), + ( + MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, + |caps| handle_code_block(caps) + ), (INLINE_CODE_BLOCK_REGEX, |caps| handle_code_block(caps)), (CORRECTION_REGEX, |caps| { let mut word_correction = caps[0].to_string(); diff --git a/src/bot/commands/tts/tts.rs b/src/bot/commands/tts/tts.rs index 90ee07d..bb97dd2 100644 --- a/src/bot/commands/tts/tts.rs +++ b/src/bot/commands/tts/tts.rs @@ -85,3 +85,78 @@ pub async fn tts(ctx: bot::Context<'_>, #[rest] text: String) -> Result<(), bot: async fn play(ctx: bot::Context<'_>, #[rest] text: String) -> Result<(), bot::Error> { tts_play(ctx, text).await } + +#[cfg(test)] +mod tests { + use super::*; + + fn matches_with_limit(regex: &str, input: &str) -> bool { + let re = Regex::new(regex).unwrap(); + + re.captures(input) + .map(|c| c[1].len() <= 16) + .unwrap_or(false) + } + + #[test] + fn inline_code_cases() { + let cases = [ + ("`hola`", true), + ("`hola mundo`", true), + ("`1234567891234567`", true), + ("```1234567891234567```", true), + ("```12345678912345678```", false), + ("`ho\nla`", false), + ("hola", false), + ("`hola", false), + ]; + + for (input, expected) in cases { + assert_eq!(matches_with_limit(INLINE_CODE_BLOCK_REGEX, input), expected); + } + } + + #[test] + fn double_code_cases() { + let cases = [ + ("``hola``", true), + ("``hola mundo``", true), + ("``1234567891234567``", true), + ("```1234567891234567```", true), + ("```12345678912345678```", false), + ("``hola\nmundo``", false), + ("hola", false), + ("``hola`", false), + ("`hola`", false), + ]; + + for (input, expected) in cases { + assert_eq!( + matches_with_limit(MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, input), + expected + ); + } + } + + #[test] + fn triple_code_cases() { + let cases = [ + ("```hola```", true), + ("```hola mundo```", true), + ("```fn main() {}```", true), + ("```1234567891234567```", true), + ("```12345678912345678```", false), + ("```\nhola\nmundo\n```", true), + ("hola", false), + ("```hola``", false), + ("``hola``", false), + ]; + + for (input, expected) in cases { + assert_eq!( + matches_with_limit(MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, input), + expected + ); + } + } +} diff --git a/src/bot/commands/tts/tts_regex.rs b/src/bot/commands/tts/tts_regex.rs index 487a0c2..624409f 100644 --- a/src/bot/commands/tts/tts_regex.rs +++ b/src/bot/commands/tts/tts_regex.rs @@ -5,7 +5,7 @@ pub const LAUGHTER_REGEX: &str = r"(?i)\b[jsadkf]{4,}\b"; pub const WHAT_REGEX: &str = r"(?i)\bq\b"; pub const WHY_REGEX: &str = r"(?i)\bxq\b"; pub const ALSO_REGEX: &str = r"(?i)\btmb\b"; -pub const INLINE_CODE_BLOCK_REGEX: &str = r"`([^`\n]*)`"; -pub const MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX: &str = r"``([^`]+)``"; +pub const INLINE_CODE_BLOCK_REGEX: &str = r"`([^`\n]+)`"; +pub const MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX: &str = r"``([^`\n]+)``"; pub const MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX: &str = r"```([\s\S]*?)```"; pub const CORRECTION_REGEX: &str = r"^\w+\*$"; From 46d573b7f87af99152f004e3406a6912e2123326 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Thu, 5 Mar 2026 02:13:09 -0600 Subject: [PATCH 06/10] Implement orb and delete the ignore attributes in the impl --- src/bot/events/godbolt/versions.rs | 37 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/bot/events/godbolt/versions.rs b/src/bot/events/godbolt/versions.rs index 0a70d7c..82a5cb2 100644 --- a/src/bot/events/godbolt/versions.rs +++ b/src/bot/events/godbolt/versions.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Deserializer}; use std::{cmp::Ordering, fmt::Display}; -#[derive(Eq, PartialOrd, Clone, Debug)] +#[derive(Eq, Clone, Debug)] pub struct OptionalVersion { major: Option, minor: Option, @@ -11,12 +11,18 @@ pub struct OptionalVersion { } impl OptionalVersion { + pub fn normalize_field(field: Option) -> Option { + field.filter(|v| *v != 0) + } + pub fn trim_ver_from_len(&mut self) { - self.extra_len -= self.to_string().len(); + self.extra_len = self.extra_len.saturating_sub(self.to_string().len()); } pub fn is_none(&self) -> bool { - self.major.is_none() && self.minor.is_none() && self.patch.is_none() + Self::normalize_field(self.major).is_none() + && Self::normalize_field(self.minor).is_none() + && Self::normalize_field(self.patch).is_none() } } @@ -50,13 +56,18 @@ impl From<&str> for OptionalVersion { impl PartialEq for OptionalVersion { fn eq(&self, other: &Self) -> bool { - self.major.filter(|m| m != &0) == other.major.filter(|m| m != &0) - && self.minor.filter(|m| m != &0) == other.minor.filter(|m| m != &0) - && self.patch.filter(|p| p != &0) == other.patch.filter(|p| p != &0) + Self::normalize_field(self.major) == Self::normalize_field(other.major) + && Self::normalize_field(self.minor) == Self::normalize_field(other.minor) + && Self::normalize_field(self.patch) == Self::normalize_field(other.patch) + } +} + +impl PartialOrd for OptionalVersion { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) } } -#[allow(clippy::derive_ord_xor_partial_ord)] impl Ord for OptionalVersion { fn cmp(&self, other: &Self) -> Ordering { let s_is_none = self.is_none(); @@ -71,10 +82,14 @@ impl Ord for OptionalVersion { } else if self.extra_len < other.extra_len { Ordering::Greater } else { - self.major - .cmp(&other.major) - .then_with(|| self.minor.cmp(&other.minor)) - .then_with(|| self.patch.cmp(&other.patch)) + Self::normalize_field(self.major) + .cmp(&Self::normalize_field(other.major)) + .then_with(|| { + Self::normalize_field(self.minor).cmp(&Self::normalize_field(other.minor)) + }) + .then_with(|| { + Self::normalize_field(self.patch).cmp(&Self::normalize_field(other.patch)) + }) } } } From a3f2ee4044e7e7f383e561f003e9206647ed7e09 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Thu, 5 Mar 2026 02:47:18 -0600 Subject: [PATCH 07/10] Implement the first contribution version file --- CONTRIBUTING.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c154355 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,48 @@ +# Guía de contribución + +Antes que todo, la comunidad de RustLangEs agradece de antemano el querer apoyar de alguna manera en el desarrollo de este proyecto, cada aporte es de gran valor para nosotros y nos impulsa a continuar desarrollando herramientas que apoyen de alguna manera a la comunidad. + +## Flujo de trabajo general + +Este proyecto sigue un flujo basado en ramas: + +- `main` — rama de produccion. Solo recibe merges desde ramas externas. + +### Pasos para contribuir + +1. Haz un fork del repositorio en GitHub. +2. Clona tu fork localmente: + ``` + git clone https://github.com/RustLangES/cangrebot.git + cd cangrebot + ``` +3. Crea una rama descriptiva desde `main`: + + ``` + git switch -c feat/nombre-de-tu-cambio + ``` +4. Realiza tus cambios y una vez que tengas la resolución prueba el comando `just`, una vez que pase con exito el comando puedes comitear con total seguridad y subir tus cambios. +5. Sube tu rama a tu fork: + ``` + git push origin feat/nombre-de-tu-cambio + ``` + + +## Como probar tus cambios + +Actualmente el projecto contiene un justfile que simula las diferentes stages del archivo CI de GitHub, dentro de este archivo existen principalmente tres comandos: + +- `check-fmt`: ejecuta el comando: `cargo fmt --all --check`, el cual valida que el codigo de Rust este formateado. +- `clippy`: ejecuta el comando: `cargo clippy --all-targets --all-features -- -D warnings`, ejecuta Clippy en todos los targets y con todas las features habilitadas, tratando las advertencias como errores para garantizar una calidad de código estricta. +- `test`: ejecuta el comando: `cargo test --verbose`, el cual ejecuta los test existentes en el proyecto dando una descripción mas detallada. + +Cada uno de estos comandos se ejecuta por defecto si dentro de la terminal ejecutas solamente el comando + +`just` + +Recomendamos ampliamente que cuando se realice el fork del proyecto, se cree una rama de la feature (o bug) a resolver en modo "Draft". + +De esta manera el proceso de CI no se ejecuta constantemente en cada commit y solamente se ejecutara una vez que se marque la pull request como "Ready to review". + +Es importante mencionar que se puede linkear la issue existente con la pull request para que esta se cierre una vez aprobada la pull request, esto se puede realizar facilmente siguiendo la estructura `Closes #numIssue`, ejemplo: +`Closes #45` From 07990239c616339544fdfc89ed29a52dd4556caf Mon Sep 17 00:00:00 2001 From: YellowDev <111405389+MarioYellowy@users.noreply.github.com> Date: Thu, 5 Mar 2026 03:08:24 -0600 Subject: [PATCH 08/10] Add checkout step to CI workflow --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a01c8a6..3f3b8e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,5 +40,7 @@ jobs: needs: [check-clippy] runs-on: ubuntu-22.04 steps: + - name: Checkout + uses: actions/checkout@v4 - name: Test run: cargo test --verbose From d2a959a83db33bdc6c3f6c971435f355c16477d9 Mon Sep 17 00:00:00 2001 From: MarioYellowy Date: Thu, 5 Mar 2026 11:40:12 -0600 Subject: [PATCH 09/10] Change name in the invocation of caps for _caps --- src/bot/commands/tts/mod.rs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/bot/commands/tts/mod.rs b/src/bot/commands/tts/mod.rs index 665d8cc..64680dd 100644 --- a/src/bot/commands/tts/mod.rs +++ b/src/bot/commands/tts/mod.rs @@ -36,8 +36,6 @@ macro_rules! replace_patterns { $({ static REGEX: LazyLock = LazyLock::new(|| Regex::new($re).expect("valid regex")); result = REGEX.replace_all(&result, |$caps: &Captures| -> Cow { - #[allow(unused_variables)] - let $caps = $caps; $body }).into_owned(); })* @@ -56,9 +54,9 @@ async fn replace_mentions( let matches: Vec<(std::ops::Range, u64)> = mention_re .captures_iter(raw_text) - .filter_map(|caps| { - let m = caps.get(0)?; - let id_str = caps.get(1)?.as_str(); + .filter_map(|_caps| { + let m = _caps.get(0)?; + let id_str = _caps.get(1)?.as_str(); let id = id_str.parse::().ok()?; Some((m.range(), id)) }) @@ -297,8 +295,8 @@ impl TtsState { ) -> Result<(), bot::Error> { let resolved = replace_mentions(guild_id, http.clone(), raw_text).await?; - fn handle_code_block(caps: &Captures) -> Cow<'static, str> { - let content = caps.get(1).map(|m| m.as_str().trim()).unwrap_or(""); + fn handle_code_block(_caps: &Captures) -> Cow<'static, str> { + let content = _caps.get(1).map(|m| m.as_str().trim()).unwrap_or(""); let word_count = content.chars().count(); if !content.is_empty() && word_count <= 16 { @@ -311,23 +309,21 @@ impl TtsState { let cleaned = replace_patterns!( resolved, [ - (LINK_REGEX, |caps| Cow::Borrowed("Enlace")), - (EMOJI_REGEX, |caps| Cow::Owned(caps[1].to_string())), + (LINK_REGEX, |_caps| Cow::Borrowed("Enlace")), + (EMOJI_REGEX, |_caps| Cow::Owned(_caps[1].to_string())), (LAUGHTER_REGEX, |_caps| Cow::Borrowed("* Risa *")), (WHAT_REGEX, |_caps| Cow::Borrowed("Qué")), (WHY_REGEX, |_caps| Cow::Borrowed("Por qué")), (ALSO_REGEX, |_caps| Cow::Borrowed("También")), - ( - MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, - |caps| handle_code_block(caps) - ), - ( - MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, - |caps| handle_code_block(caps) - ), - (INLINE_CODE_BLOCK_REGEX, |caps| handle_code_block(caps)), - (CORRECTION_REGEX, |caps| { - let mut word_correction = caps[0].to_string(); + (MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, |_caps| { + handle_code_block(_caps) + }), + (MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, |_caps| { + handle_code_block(_caps) + }), + (INLINE_CODE_BLOCK_REGEX, |_caps| handle_code_block(_caps)), + (CORRECTION_REGEX, |_caps| { + let mut word_correction = _caps[0].to_string(); word_correction.pop(); Cow::Owned(format!("Corrijo... {}", word_correction)) }), From 5f02cb970471af0ab9bd0ebb8d01e48bb2c3faf1 Mon Sep 17 00:00:00 2001 From: Chiwa <74442646+gg0074x@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:01:59 -0300 Subject: [PATCH 10/10] WHY --- src/bot/commands/tts/mod.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bot/commands/tts/mod.rs b/src/bot/commands/tts/mod.rs index 64680dd..4d38163 100644 --- a/src/bot/commands/tts/mod.rs +++ b/src/bot/commands/tts/mod.rs @@ -54,9 +54,9 @@ async fn replace_mentions( let matches: Vec<(std::ops::Range, u64)> = mention_re .captures_iter(raw_text) - .filter_map(|_caps| { - let m = _caps.get(0)?; - let id_str = _caps.get(1)?.as_str(); + .filter_map(|caps| { + let m = caps.get(0)?; + let id_str = caps.get(1)?.as_str(); let id = id_str.parse::().ok()?; Some((m.range(), id)) }) @@ -295,8 +295,8 @@ impl TtsState { ) -> Result<(), bot::Error> { let resolved = replace_mentions(guild_id, http.clone(), raw_text).await?; - fn handle_code_block(_caps: &Captures) -> Cow<'static, str> { - let content = _caps.get(1).map(|m| m.as_str().trim()).unwrap_or(""); + fn handle_code_block(caps: &Captures) -> Cow<'static, str> { + let content = caps.get(1).map(|m| m.as_str().trim()).unwrap_or(""); let word_count = content.chars().count(); if !content.is_empty() && word_count <= 16 { @@ -310,20 +310,20 @@ impl TtsState { resolved, [ (LINK_REGEX, |_caps| Cow::Borrowed("Enlace")), - (EMOJI_REGEX, |_caps| Cow::Owned(_caps[1].to_string())), + (EMOJI_REGEX, |caps| Cow::Owned(caps[1].to_string())), (LAUGHTER_REGEX, |_caps| Cow::Borrowed("* Risa *")), (WHAT_REGEX, |_caps| Cow::Borrowed("Qué")), (WHY_REGEX, |_caps| Cow::Borrowed("Por qué")), (ALSO_REGEX, |_caps| Cow::Borrowed("También")), - (MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, |_caps| { - handle_code_block(_caps) + (MULTI_LINE_TRIPLE_CODE_BLOCK_REGEX, |caps| { + handle_code_block(caps) }), - (MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, |_caps| { - handle_code_block(_caps) + (MULTI_LINE_DOUBLE_CODE_BLOCK_REGEX, |caps| { + handle_code_block(caps) }), - (INLINE_CODE_BLOCK_REGEX, |_caps| handle_code_block(_caps)), - (CORRECTION_REGEX, |_caps| { - let mut word_correction = _caps[0].to_string(); + (INLINE_CODE_BLOCK_REGEX, |caps| handle_code_block(caps)), + (CORRECTION_REGEX, |caps| { + let mut word_correction = caps[0].to_string(); word_correction.pop(); Cow::Owned(format!("Corrijo... {}", word_correction)) }),