Minor bugfixes
parent
f9ac5fa3e6
commit
61b8640864
|
@ -115,13 +115,15 @@ pub mod bot {
|
|||
}
|
||||
}
|
||||
|
||||
let spam_info = SpamInfo::new();
|
||||
|
||||
let bot = Bot {
|
||||
client,
|
||||
info: creds,
|
||||
joined_room,
|
||||
swear_list: swear_list.clone(),
|
||||
database_handle: db,
|
||||
spam_info: SpamInfo::new(),
|
||||
spam_info,
|
||||
members_list: members_list.clone(),
|
||||
};
|
||||
|
||||
|
@ -266,8 +268,6 @@ pub mod bot {
|
|||
|
||||
async fn detect_spam(&mut self, event: &OriginalSyncRoomMessageEvent) {
|
||||
|
||||
println!("{:?}", self.spam_info.author_msg_times);
|
||||
|
||||
let author = self
|
||||
.joined_room
|
||||
.get_member(&event.sender)
|
||||
|
@ -284,8 +284,6 @@ pub mod bot {
|
|||
msg_times.push(curr_utc)
|
||||
}
|
||||
|
||||
println!("{:?}", self.spam_info.author_msg_times);
|
||||
|
||||
let expire_time: i64 = curr_utc - self.spam_info.detection_window;
|
||||
|
||||
let mut expired_msgs: Vec<i64> = vec![];
|
||||
|
@ -304,7 +302,6 @@ pub mod bot {
|
|||
.unwrap()
|
||||
.retain(|value| *value != msg);
|
||||
}
|
||||
println!("{:?}", self.spam_info.author_msg_times);
|
||||
|
||||
if i64::try_from(
|
||||
self.spam_info
|
||||
|
|
|
@ -19,5 +19,5 @@ async fn main() {
|
|||
}
|
||||
let config_path = &args[1];
|
||||
let creds = BotUserInfo::get_info(config_path).unwrap();
|
||||
Bot::bot_login(creds).await;
|
||||
let _ = Bot::bot_login(creds).await;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ pub mod utils {
|
|||
}
|
||||
|
||||
pub fn detect_swear_from_message(swear_list: &Vec<String>, message: &str) -> bool {
|
||||
let message_words = message.split_whitespace();
|
||||
let lowercase_message = message.to_lowercase();
|
||||
let message_words = lowercase_message.split_whitespace();
|
||||
for words in message_words {
|
||||
for swear in swear_list {
|
||||
if words.contains(swear) {
|
||||
|
@ -96,7 +97,7 @@ pub mod utils {
|
|||
let msg_length: f32 = characters.len() as f32;
|
||||
let mut counter: f32 = 0.0;
|
||||
for char in characters {
|
||||
if !char.is_lowercase() {
|
||||
if !char.is_lowercase() && char.is_alphabetic() {
|
||||
counter += 1.0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue