From 985d6bd787c07ea65804d5c079537fb8d805075f Mon Sep 17 00:00:00 2001 From: Jokler Date: Tue, 28 Jan 2020 03:04:58 +0100 Subject: Block bots from joining channels with other bots --- src/teamspeak.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/teamspeak.rs') diff --git a/src/teamspeak.rs b/src/teamspeak.rs index 5dd80ba..b429869 100644 --- a/src/teamspeak.rs +++ b/src/teamspeak.rs @@ -115,10 +115,14 @@ impl TeamSpeakConnection { tokio::run(send_packet); } - pub fn channel_path_of_user(&self, id: ClientId) -> String { + pub fn channel_of_user(&self, id: ClientId) -> Option { + Some(self.conn.lock().clients.get(&id)?.channel) + } + + pub fn channel_path_of_user(&self, id: ClientId) -> Option { let conn = self.conn.lock(); - let channel_id = conn.clients.get(&id).expect("can find poke sender").channel; + let channel_id = conn.clients.get(&id)?.channel; let mut channel = conn .channels @@ -142,7 +146,7 @@ impl TeamSpeakConnection { path.push_str(name); } - path + Some(path) } pub fn my_channel(&self) -> ChannelId { -- cgit v1.2.3-70-g09d2