Adicionado o is_template na verificação.
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -308,26 +308,33 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// Filter chats that have less that specified ammount of talks with support agent form the last queue transfer
|
// Filter chats that have less that specified ammount of talks with support agent form the last queue transfer
|
||||||
let found = talk_histories
|
let found = talk_histories
|
||||||
.as_array()
|
.as_array()
|
||||||
.expect("Wrong message type received from talk histories")
|
.expect("Wrong message type received from talk histories.")
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.find(|(pos, message_object)| {
|
.find(|(pos, message_object)| {
|
||||||
let message = message_object["message"]
|
let message = message_object["message"]
|
||||||
.as_str()
|
.as_str()
|
||||||
.expect("Failed to decode message as string");
|
.expect("Failed to decode message as string.");
|
||||||
|
let template_id = message_object["is_template"]
|
||||||
|
.as_bool()
|
||||||
|
.unwrap_or(true);
|
||||||
|
// println!("Conteudo do template_id da mensagem {}: {:?}", pos, template_id);
|
||||||
let found = message.find(
|
let found = message.find(
|
||||||
"Atendimento transferido para a fila [NovaNet -> Atendimento -> NOC - Clientes]",
|
"Atendimento transferido para a fila [NovaNet -> Atendimento -> NOC - Clientes]",
|
||||||
);
|
);
|
||||||
found.is_some()
|
|
||||||
|
found.is_some() || template_id
|
||||||
});
|
});
|
||||||
|
|
||||||
match found {
|
match found {
|
||||||
None => {
|
None => {
|
||||||
|
println!("Descartado - Não encontrou a transferencia ou o template no chat. 1");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(pos) => {
|
Some(pos) => {
|
||||||
let pos_found = pos.0;
|
let pos_found = pos.0;
|
||||||
if pos_found < MINIMUM_NUMBER_OF_MESSAGES_WITH_AGENT_TO_EVALUATE {
|
if pos_found < MINIMUM_NUMBER_OF_MESSAGES_WITH_AGENT_TO_EVALUATE {
|
||||||
|
println!("Descartado - Chat não tem o número minimo de mensagens com agente.");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,6 +346,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.unwrap_or("unknown_user")
|
.unwrap_or("unknown_user")
|
||||||
== "PipeBot"
|
== "PipeBot"
|
||||||
{
|
{
|
||||||
|
println!("Descartado - Chat finalizado pelo pipebot.");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +354,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
if json["finished_at"].to_string()
|
if json["finished_at"].to_string()
|
||||||
== "null"
|
== "null"
|
||||||
{
|
{
|
||||||
|
println!("Descartado - Chat não finalizado.");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,14 +373,17 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.find(&keyword.to_uppercase())
|
.find(&keyword.to_uppercase())
|
||||||
.is_some()
|
.is_some()
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
let found2 = message_object["is_template"]
|
let found2 = message_object["is_template"]
|
||||||
.as_bool()
|
.as_bool()
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
let found = found1 || found2;
|
let found = found1 || found2;
|
||||||
found
|
*/
|
||||||
|
found1
|
||||||
});
|
});
|
||||||
|
|
||||||
if filter_keywords_found {
|
if filter_keywords_found {
|
||||||
|
println!("Descartado - Encontrou uma frase do filtro no chat.");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,9 +413,11 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let message = message_object["message"]
|
let message = message_object["message"]
|
||||||
.as_str()
|
.as_str()
|
||||||
.expect("Failed to decode message as string");
|
.expect("Failed to decode message as string");
|
||||||
let found = message.find("Atendimento entregue da fila de espera para o agente [NOC - ");
|
let found = message.find("Atendimento entregue da fila de espera para o agente [NOC");
|
||||||
let found = message.find("Olá, faço parte do setor de Redes aqui da NovaNet.");
|
let is_template = message_object["is_template"]
|
||||||
found.is_some()
|
.as_bool()
|
||||||
|
.unwrap_or(true);
|
||||||
|
found.is_some() || is_template
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find first agent message sent after the last bot message
|
// Find first agent message sent after the last bot message
|
||||||
@@ -602,7 +616,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
|
|
||||||
// Send folder to email
|
// Send folder to email
|
||||||
let recipients = "Wilson da Conceição Oliveira <wilson.oliveira@nova.net.br>, Nicolas Borges da Silva <nicolas.borges@nova.net.br>";
|
let recipients = "Nicolas Borges da Silva <nicolas.borges@nova.net.br>, wilson@nova.net.br";
|
||||||
println!("Trying to send email... Recipients {recipients}");
|
println!("Trying to send email... Recipients {recipients}");
|
||||||
|
|
||||||
send_mail_util::send_mail_util::send_email(
|
send_mail_util::send_mail_util::send_email(
|
||||||
|
|||||||
Reference in New Issue
Block a user