diff --git a/.gitignore b/.gitignore index d858fad..c33d999 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ credentials.ini config.ini list.txt members_database/ +spam_tracking_database/ diff --git a/Dockerfile b/Dockerfile index fb134fa..29ddc7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ FROM debian:stable-slim ARG package ADD $package ./ -COPY list.txt . RUN chmod +x matrix-modbot RUN touch config.ini CMD ["./matrix-modbot", "config.ini"] -HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl --fail http://localhost:5000/health || exit 1 diff --git a/src/bot.rs b/src/bot.rs index f697558..2d31145 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -318,7 +318,7 @@ pub mod bot { data_vec.push(curr_utc); - if data_vec.len() > 5 && author_name != self.info.user_id { + if data_vec.len() > 3 && author_name != self.info.user_id { self.delete_message_from_room(&event.event_id, "Spamming") .await; self.update_reputation_for_member(&author, -1) diff --git a/src/utils.rs b/src/utils.rs index 28c6f7a..05e0632 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -113,6 +113,7 @@ pub mod utils { } } - counter / msg_length >= 0.8 + (counter / msg_length) >= 0.65 } + } diff --git a/tests/test_caps_detection.rs b/tests/test_caps_detection.rs new file mode 100644 index 0000000..f206192 --- /dev/null +++ b/tests/test_caps_detection.rs @@ -0,0 +1,11 @@ +#[cfg(test)] +mod tests { + use matrix_modbot::utils::utils::detect_caps; + + #[test] + fn test_caps_detection() { + assert!(detect_caps("FULL CAPSSSSSS")); + assert!(!detect_caps("Not Full Caps But There Are Some Caps")); + assert!(detect_caps("CAPs BUT N0T FuLLY")); + } +} diff --git a/tests/test_swear_detection.rs b/tests/test_swear_detection.rs index 2bcab73..39c5bf3 100644 --- a/tests/test_swear_detection.rs +++ b/tests/test_swear_detection.rs @@ -8,6 +8,7 @@ mod tests { let creds = BotUserInfo::get_info("tests/test_creds.ini").unwrap(); let swear_list = create_swear_list(&creds.swear_list_url).await.unwrap(); assert!(detect_swear_from_message(&swear_list, "fuck you")); + assert!(detect_swear_from_message(&swear_list, "FUCK YOU IN CAPS")); assert!(!detect_swear_from_message( &swear_list, "This isn't a swear"