diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-03-26 23:44:49 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-03-26 23:44:49 +0200 |
| commit | d9e0dcbeff3cbd63992a60895c7567430ce333d7 (patch) | |
| tree | f624af294673b99d202e9bce2efe619a00edbcd4 | |
| parent | abc0b5bccb0029c2e14d3cf1d304945480bc27d3 (diff) | |
| download | frippy-d9e0dcbeff3cbd63992a60895c7567430ce333d7.tar.gz frippy-d9e0dcbeff3cbd63992a60895c7567430ce333d7.zip | |
Fix unicode flag in the sed plugin
| -rw-r--r-- | src/plugins/sed.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/sed.rs b/src/plugins/sed.rs index 8d8cb0d..8ccb2f7 100644 --- a/src/plugins/sed.rs +++ b/src/plugins/sed.rs @@ -63,7 +63,7 @@ impl Sed { let mut case_insens = false; let mut ign_whitespace = false; let mut swap_greed = false; - let mut disable_unicode = false; + let mut enable_unicode = true; let captures = RE.captures(message).unwrap(); debug!("{:?}", captures); @@ -78,13 +78,13 @@ impl Sed { case_insens = flags.contains('i'); ign_whitespace = flags.contains('x'); swap_greed = flags.contains('U'); - disable_unicode = !flags.contains('u'); + enable_unicode = !flags.contains('u'); } let user_re = RegexBuilder::new(&first) .case_insensitive(case_insens) .ignore_whitespace(ign_whitespace) - .unicode(disable_unicode) + .unicode(enable_unicode) .swap_greed(swap_greed) .build() .context(ErrorKind::InvalidRegex)?; @@ -120,7 +120,13 @@ impl Plugin for Sed { if RE.is_match(content) { let result = match self.run_regex(channel, content) { Ok(msg) => client.send_privmsg(channel, &msg), - Err(e) => client.send_notice(channel, &e.to_string()), + Err(e) => match e.kind() { + ErrorKind::InvalidRegex => { + let err = e.cause().unwrap().to_string(); + client.send_notice(channel, &err.replace('\n', "\r\n")) + } + _ => client.send_notice(channel, &e.to_string()), + }, }; match result { |
