|
|
|
@ -4,7 +4,7 @@ use actix_web::Error;
|
|
|
|
|
use chrono::Utc;
|
|
|
|
|
use futures_util::StreamExt;
|
|
|
|
|
use harsh::Harsh;
|
|
|
|
|
use serde_json::Value;
|
|
|
|
|
use serde_json::{Map, Value};
|
|
|
|
|
|
|
|
|
|
use crate::{client, Client};
|
|
|
|
|
|
|
|
|
@ -85,13 +85,22 @@ impl WotLog {
|
|
|
|
|
|
|
|
|
|
/// Read and parse the log
|
|
|
|
|
pub fn parse_log(self: &mut Self) -> Result<(), Error> {
|
|
|
|
|
self.json = match self.client {
|
|
|
|
|
Client::Mudlet => client::mudlet::parse_log(&self.raw)?,
|
|
|
|
|
Client::TinTin => Value::Null,
|
|
|
|
|
Client::ZMud => Value::Null,
|
|
|
|
|
Client::None => Value::Null,
|
|
|
|
|
let mut map: Map<String, Value> = Map::new();
|
|
|
|
|
map.insert("id".into(), self.id.clone().into());
|
|
|
|
|
map.insert("player".into(), self.player.clone().into());
|
|
|
|
|
map.insert("title".into(), self.title.clone().into());
|
|
|
|
|
|
|
|
|
|
match self.client {
|
|
|
|
|
Client::Mudlet => {
|
|
|
|
|
map.insert("replay".into(), client::mudlet::parse_log(&self.raw)?.into());
|
|
|
|
|
}
|
|
|
|
|
Client::TinTin => (),
|
|
|
|
|
Client::ZMud => (),
|
|
|
|
|
Client::None => (),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.json = map.into();
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|