From ecdcbab6dcbb2a0d1e510bdf2f65991866689fc7 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 3 Jul 2020 20:52:52 -0400 Subject: [PATCH] refine messaging --- regexes.dhall | 4 +++- src/main.rs | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/regexes.dhall b/regexes.dhall index 317205f..36fe972 100644 --- a/regexes.dhall +++ b/regexes.dhall @@ -3,4 +3,6 @@ let Rule = , default = { regex = "", why = "" } } -in [ Rule::{ regex = "(n|z)igg(er|a)", why = "racism" } ] +in [ Rule::{ regex = "(n|z)igg(er|a)", why = "racism" } + , Rule::{ regex = "(hot|cute)", why = "Cadey is testing" } + ] diff --git a/src/main.rs b/src/main.rs index 2020e9e..e491f75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,16 +46,16 @@ impl FirehoseAdaptor for Rules { let mut found = false; for rule in &self.0 { - if rule.regex.is_match(&img.description) { + if rule.regex.is_match(&img.description.to_lowercase()) { found = true; - buf.push_str(&format!("\n- match on rule {} ({})", rule.raw, rule.why)); + buf.push_str(&format!("\n- match on rule `{}` ({})", rule.raw, rule.why)); } } if found { discord_webhook::execute( self.1.discord_webhook_url.clone(), - Body::new(format!("matches found on {}: \n{}", img.view_url, buf)), + Body::new(format!("matches found on <{}>:{}", img.view_url, buf)), ) .await?; } @@ -68,9 +68,9 @@ impl FirehoseAdaptor for Rules { let mut found = false; for rule in &self.0 { - if rule.regex.is_match(&cmt.body) { + if rule.regex.is_match(&cmt.body.to_lowercase()) { found = true; - buf.push_str(&format!("\n- match on rule {} ({})", rule.raw, rule.why)); + buf.push_str(&format!("\n- match on rule `{}` ({})", rule.raw, rule.why)); } } @@ -78,7 +78,7 @@ impl FirehoseAdaptor for Rules { discord_webhook::execute( self.1.discord_webhook_url.clone(), Body::new(format!( - "matches found on https://furbooru.org/{}#comment_{}: \n{}", + "matches found on :{}", cmt.image_id, cmt.id, buf )), ) @@ -98,6 +98,7 @@ async fn main() -> Result<()> { let mut compiled_rules: Vec = Vec::new(); for rule in rexes { + println!("{} -> {}", rule.regex, rule.why); compiled_rules.push(CompiledRule { raw: rule.regex.clone(), regex: Regex::new(rule.regex.as_str())?,