From 22579ced3d1d847a14683fe3b47fa2076df01751 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Thu, 5 Nov 2020 00:44:04 +0100 Subject: add mute feature --- mumlib/src/state.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'mumlib/src/state.rs') diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index b6b4039..0540f14 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -130,9 +130,19 @@ pub struct User { pub deaf: bool, // by admin } +macro_rules! true_to_str { + ($condition:expr, $res:expr) => {if $condition { $res } else { "" }}; +} + impl Display for User { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.name) + write!(f, "{} {}{}{}{}{}", + self.name, + true_to_str!(self.suppress, "s"), + true_to_str!(self.self_mute, "M"), + true_to_str!(self.self_deaf, "D"), + true_to_str!(self.mute, "m"), + true_to_str!(self.deaf, "d")) } } -- cgit v1.2.1