mrsbfh

Matrix-Rust-SDK-Bot-Framework-Helper
git clone git://archive.git.mtrnord.blog/MTRNord/mrsbfh.git
Log | Files | Refs | README

commit aa98d9c65418294d3080ddeb422873a71af5cf8e
parent e45ccccc808f68b4c03fe4f894ef1e54a67016f7
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sun, 31 Jan 2021 18:59:47 +0100

fix: Normalize all inputs before spliting to ensure we split correctly

Diffstat:
Mmrsbfh-macros/Cargo.toml | 3+--
Mmrsbfh-macros/src/lib.rs | 2++
Mmrsbfh/Cargo.toml | 5+++--
3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/mrsbfh-macros/Cargo.toml b/mrsbfh-macros/Cargo.toml @@ -11,4 +11,4 @@ proc-macro = true syn = { version= "1.0", features=["full"] } quote = "1.0" convert_case = "0.4.0" -proc-macro2 = "1.0" -\ No newline at end of file +proc-macro2 = "1.0" diff --git a/mrsbfh-macros/src/lib.rs b/mrsbfh-macros/src/lib.rs @@ -333,6 +333,8 @@ pub fn commands(_: TokenStream, input: TokenStream) -> TokenStream { let cloned_config = self.config.clone(); let cloned_client = self.client.clone(); tokio::spawn(async move { + let whitespace_deduplicator_magic = Regex::new(r"\s+").unwrap(); + let normalized_body = whitespace_deduplicator_magic.replace_all(&msg_body, " "); let mut split = msg_body.split_whitespace(); let command_raw = split.next().expect("This is not a command"); diff --git a/mrsbfh/Cargo.toml b/mrsbfh/Cargo.toml @@ -26,4 +26,6 @@ serde = "1.0" serde_yaml = "0.8.13" serde_json = "1" -pulldown-cmark = "0.8.0" # For generating the help text -\ No newline at end of file +pulldown-cmark = "0.8.0" # For generating the help text + +regex = "1.4.3"