Modify keywords; cleanup debug.rs

This commit is contained in:
0xf8 2023-04-16 21:10:39 -04:00
parent d94095e8d9
commit 36860c9314
Signed by: 0xf8
GPG Key ID: 446580D758689584
2 changed files with 22 additions and 32 deletions

View File

@ -1,7 +1,7 @@
{ {
"sections": { "sections": {
"18+": { "18+": {
"threshold": 3, "threshold": 4,
"requiredKeywords": [ "requiredKeywords": [
"sex", "sex",
"nude", "nude",
@ -14,37 +14,38 @@
"pay", "pal", "pay", "pal",
"buy", "buy",
"sell", "sell",
"on",
"message", "message",
"meet", "meet",
"check", "check",
"card" "card",
"discord"
] ]
}, },
"Investment": { "Investment": {
"threshold": 4, "threshold": 3,
"requiredKeywords": [ "requiredKeywords": [
"tg", "t.me/", "crypto",
"invest",
"crypto", "market",
"profit", "profit",
"my commission", "my commission",
"cashout", "cash out", "tg", "t.me",
"million",
"cash.app", "cash.app",
"l.wl.co/", ".app.link/" "l.wl.co/", ".app.link/"
], ],
"keywords": [ "keywords": [
"earn", "earning", "earn", "earning",
"make", "making", "made", "make", "making", "made",
"buy", "buy", "invest",
"send", "cashout", "cash out",
"send", "market",
"interested", "interested",
"btc", "bitcoin", "btc", "bitcoin",
"eth", "ethereum", "etherium", "eth", "ethereum", "etherium",
"$", "usd", "$", "usd",
"million",
"asking me how", "asking me how",
"cash", "whats", "app", "cash", "whatsapp",
"tele", "gram", "telegram",
"👇", "👆️" "👇", "👆️"
] ]
} }

View File

@ -3,8 +3,7 @@ use matrix_sdk::{
ruma::events::room::message::RoomMessageEventContent, ruma::events::room::message::RoomMessageEventContent,
}; };
use crate::{ use crate::{
judge::{Judgement, JudgementResult}, judge::Judgement,
keywords::KeywordSection,
CONFIG, CONFIG,
}; };
@ -16,7 +15,6 @@ impl Debug {
let mut result_report: Vec<(String, String)> = vec![]; let mut result_report: Vec<(String, String)> = vec![];
let res: (JudgementResult, Option<KeywordSection>) = (|| {
for section in sections { for section in sections {
let (hits, hit_required) = section.1.find(judge.text.to_owned()); let (hits, hit_required) = section.1.find(judge.text.to_owned());
@ -24,16 +22,7 @@ impl Debug {
format!("\"{}\": \"{hits}\", {hit_required} ", section.0), format!("\"{}\": \"{hits}\", {hit_required} ", section.0),
format!("<code>{}</code>: <code>{hits}</code>, <code>{hit_required}</code>", section.0) format!("<code>{}</code>: <code>{hits}</code>, <code>{hit_required}</code>", section.0)
)); ));
if hit_required && hits >= section.1.threshold {
return (JudgementResult::LikelyScam, Some(section.1))
} else if hits >= section.1.threshold {
return (JudgementResult::MaybeScam, Some(section.1))
} }
}
(JudgementResult::Ok, None)
})();
let mut full_report: (String, String) = ("".to_string(), "".to_string()); let mut full_report: (String, String) = ("".to_string(), "".to_string());