From 5cb7ca51933c7c7f5803b15c42f75263d5d6c304 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 19 Feb 2024 02:02:17 +0100 Subject: [PATCH] fix: exclude self from user list --- src/session.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/session.rs b/src/session.rs index 5690c75..5604057 100644 --- a/src/session.rs +++ b/src/session.rs @@ -39,6 +39,7 @@ impl Session { } pub async fn users(host: &str, port: Option, username: Option, password: Option) -> std::io::Result> { + let username = Some(username.unwrap_or_else(|| ".mumble-stats-api".to_string())); let mut channel = ControlChannel::new(host, port).await?; let version = proto::Version { version_v1: None, @@ -48,7 +49,7 @@ impl Session { os_version: None, }; let authenticate = proto::Authenticate { - username: Some(username.unwrap_or_else(|| ".mumble-stats-api".to_string())), + username: username.clone(), password, tokens: Vec::new(), celt_versions: Vec::new(), @@ -69,8 +70,12 @@ impl Session { match channel.recv().await? { // Ok(tcp::proto::Packet::TextMessage(msg)) => tracing::info!("{}", msg.message), // Ok(tcp::proto::Packet::ChannelState(channel)) => tracing::info!("discovered channel: {:?}", channel.name), - proto::Packet::UserState(user) => users.push(user.into()), proto::Packet::ServerSync(_sync) => break Ok(users), + proto::Packet::UserState(user) => { + if user.name != username { + users.push(user.into()); + } + }, pkt => tracing::debug!("ignoring packet {:#?}", pkt), } }