diff options
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | mumctl/src/main.rs | 2 | ||||
| -rw-r--r-- | mumd/Cargo.toml | 1 | ||||
| -rw-r--r-- | mumd/src/state.rs | 10 | ||||
| -rw-r--r-- | mumlib/Cargo.toml | 2 | ||||
| -rw-r--r-- | mumlib/src/command.rs | 3 |
6 files changed, 13 insertions, 7 deletions
@@ -139,6 +139,7 @@ dependencies = [ "libc", "num-integer", "num-traits", + "serde", "time", "winapi", ] @@ -814,6 +815,7 @@ version = "0.4.0" dependencies = [ "bincode", "bytes", + "chrono", "cpal", "dasp_frame", "dasp_interpolate", diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index bde24a1..8b0eeb2 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -366,7 +366,7 @@ fn match_opt() -> Result<(), Error> { for response in send_command_multi(MumCommand::PastMessages { block: follow })? { match response { Ok(Some(CommandResponse::PastMessage { message })) => { - println!("{}: {}", message.1, message.0) + println!("[{}] {}: {}", message.0.format("%d %b %H:%M"), message.2, message.1) } Ok(_) => unreachable!("Response should only be a Some(PastMessages)"), Err(e) => error!("{}", e), diff --git a/mumd/Cargo.toml b/mumd/Cargo.toml index d8e2635..1e8e63f 100644 --- a/mumd/Cargo.toml +++ b/mumd/Cargo.toml @@ -42,6 +42,7 @@ tokio-stream = "0.1.0" tokio-native-tls = "0.3" tokio-util = { version = "0.6", features = ["codec", "net"] } bincode = "1.3.2" +chrono = "0.4" libnotify = { version = "1.0", optional = true } diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 84583e0..4530e46 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -8,8 +8,9 @@ use crate::network::tcp::{TcpEvent, TcpEventData}; use crate::network::{ConnectionInfo, VoiceStreamType}; use crate::notifications; use crate::state::server::Server; - use crate::state::user::UserDiff; + +use chrono::NaiveDateTime; use log::*; use mumble_protocol::control::msgs; use mumble_protocol::control::ControlPacket; @@ -72,7 +73,7 @@ pub struct State { server: Option<Server>, audio_input: AudioInput, audio_output: AudioOutput, - message_buffer: Vec<(String, u32)>, + message_buffer: Vec<(NaiveDateTime, String, u32)>, phase_watcher: (watch::Sender<StatePhase>, watch::Receiver<StatePhase>), } @@ -266,7 +267,7 @@ impl State { } pub fn register_message(&mut self, msg: (String, u32)) { - self.message_buffer.push(msg); + self.message_buffer.push((chrono::Local::now().naive_local(), msg.0, msg.1)); } pub fn broadcast_phase(&self, phase: StatePhase) { @@ -650,6 +651,7 @@ pub fn handle_command( Box::new(move |data, sender| { if let TcpEventData::TextMessage(a) = data { let message = ( + chrono::Local::now().naive_local(), a.get_message().to_owned(), ref_state .read() @@ -669,7 +671,7 @@ pub fn handle_command( let messages = std::mem::take(&mut state.message_buffer); let messages: Vec<_> = messages .into_iter() - .map(|(msg, user)| (msg, state.get_user_name(user).unwrap())) + .map(|(timestamp, msg, user)| (timestamp, msg, state.get_user_name(user).unwrap())) .map(|e| Ok(Some(CommandResponse::PastMessage { message: e }))) .collect(); diff --git a/mumlib/Cargo.toml b/mumlib/Cargo.toml index 5c9d4e1..5ec9365 100644 --- a/mumlib/Cargo.toml +++ b/mumlib/Cargo.toml @@ -13,7 +13,7 @@ readme = "../README.md" [dependencies] colored = "2" -chrono = "0.4" +chrono = { version = "0.4", features = [ "serde" ] } dirs = "3" fern = "0.6" log = "0.4" diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 351d7f6..27ca60c 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -1,5 +1,6 @@ use crate::state::{Channel, Server}; +use chrono::NaiveDateTime; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] @@ -63,7 +64,7 @@ pub enum CommandResponse { server_state: Server, }, PastMessage { - message: (String, String), + message: (NaiveDateTime, String, String), }, } |
