forked from jelson.rodrigues/piperun-bot
chore: update filtering
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -1,8 +1,6 @@
|
|||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::{any::Any, env, fmt::format, iter, time::Duration};
|
use std::{any::Any, env, fmt::format, iter, time::Duration};
|
||||||
|
|
||||||
// use http::{self, response};
|
|
||||||
|
|
||||||
use chrono::{self, Timelike};
|
use chrono::{self, Timelike};
|
||||||
use dotenv;
|
use dotenv;
|
||||||
use ipaddress;
|
use ipaddress;
|
||||||
@@ -291,6 +289,16 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
if network_sector_mentioned.is_some() {return None;}
|
if network_sector_mentioned.is_some() {return None;}
|
||||||
|
|
||||||
|
// Password change ticket
|
||||||
|
let password_change_keywords = ["trocar a senha", "troca de senha", "troca senha", "alterar senha", "altera senha"];
|
||||||
|
let password_change_identified = talk_histories.as_array().expect("Wrong message type received from talk histories").into_iter().any(|message_object|{
|
||||||
|
let message = message_object["message"].as_str().expect("Failed to decode message as string");
|
||||||
|
let found = password_change_keywords.iter().any(|keyword|{message.to_uppercase().find(&keyword.to_uppercase()).is_some()});
|
||||||
|
found
|
||||||
|
});
|
||||||
|
|
||||||
|
if password_change_identified {return None;}
|
||||||
|
|
||||||
// Filter Bot finished chats
|
// Filter Bot finished chats
|
||||||
if json["agent"]["user"]["name"].as_str().unwrap_or("unknown_user") == "PipeBot" {return None;}
|
if json["agent"]["user"]["name"].as_str().unwrap_or("unknown_user") == "PipeBot" {return None;}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user