diff --git a/Cargo.toml b/Cargo.toml index 7d56b91..3eeabc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ overflow-checks = false debug = "none" debug-assertions = false strip = true -lto = "fat" panic = "abort" diff --git a/src/error_codes.rs b/src/error_codes.rs index 846b3b3..d722712 100644 --- a/src/error_codes.rs +++ b/src/error_codes.rs @@ -59,7 +59,7 @@ static CHEESEBURGER_REGEX: Lazy = Lazy::new(|| Regex::new("[Cc]heeseburger(s)?").expect("invalid regex")); static AY_REGEX: Lazy = - Lazy::new(|| Regex::new("[Aa][Yy]*").expect("invalid regex")); + Lazy::new(|| Regex::new("(^|\\s)[Aa][Yy]+($|\\s)").expect("invalid regex")); pub struct ErrorCodeHandler; @@ -166,7 +166,14 @@ impl EventHandler for ErrorCodeHandler { for ay in AY_REGEX.find_iter(&msg.content){ output += &msg.content[lastpos..ay.start()]; - let str = ay.as_str(); + lastpos = ay.end(); + + let mut str = ay.as_str(); + + if str.starts_with(' '){ + str = &str[1..]; + output.push(' '); + } let mut chars = str.chars(); @@ -181,16 +188,23 @@ impl EventHandler for ErrorCodeHandler { } for char in chars{ - if char.is_lowercase(){ - output.push('o') - } else { - output.push('O') + if char == ' '{ + output.push(' '); + break; } - } - lastpos = ay.end(); + if char.is_lowercase(){ + output.push('o'); + } else { + output.push('O'); + } + + + } } + output += &msg.content[lastpos..]; + msg.reply(&ctx.http, output).await.ok(); } }