Minor bugfixes

main
David 2023-01-11 12:52:08 +01:00
parent 780538cbd1
commit 6a745cfd54
6 changed files with 16 additions and 4 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ credentials.ini
config.ini
list.txt
members_database/
spam_tracking_database/

View File

@ -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

View File

@ -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)

View File

@ -113,6 +113,7 @@ pub mod utils {
}
}
counter / msg_length >= 0.8
(counter / msg_length) >= 0.65
}
}

View File

@ -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"));
}
}

View File

@ -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"