Adição de filtro de type=out no .txt
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -373,10 +373,6 @@ fn main() -> anyhow::Result<()> {
|
||||
let json = messages.unwrap();
|
||||
let talk_histories = &json["talk_histories"];
|
||||
|
||||
// dbg!(&talk_histories);
|
||||
|
||||
// talk_histories.as_array().unwrap().into_iter().enumerate().for_each(|(pos, message_obj)|{println!("{}: {}", pos, message_obj["message"])});
|
||||
|
||||
// find the bot transfer message
|
||||
let bot_transfer_message = talk_histories
|
||||
.as_array()
|
||||
@@ -490,6 +486,14 @@ fn main() -> anyhow::Result<()> {
|
||||
.expect("Wrong message type received from talk histories")
|
||||
.iter()
|
||||
.rev()
|
||||
//filtro para escrever somente as mensagens out no .txt
|
||||
.filter(|(message_object)| {
|
||||
let message_type = message_object["type"]
|
||||
.as_str()
|
||||
.expect("Failed to decode message as string");
|
||||
message_type == "out".to_string()
|
||||
})
|
||||
//fim do filtro
|
||||
.map(|message_object| {
|
||||
let new_json_filtered = format!(
|
||||
"{{
|
||||
@@ -503,7 +507,6 @@ fn main() -> anyhow::Result<()> {
|
||||
message_object["type"],
|
||||
message_object["user"]["name"]
|
||||
);
|
||||
// println!("{}", new_json_filtered);
|
||||
new_json_filtered
|
||||
})
|
||||
.reduce(|acc, e| format!("{acc}\n{e}"))
|
||||
|
||||
Reference in New Issue
Block a user