aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bot/master.rs5
-rw-r--r--src/bot/music.rs9
-rw-r--r--src/teamspeak/mod.rs18
3 files changed, 16 insertions, 16 deletions
diff --git a/src/bot/master.rs b/src/bot/master.rs
index 1821ac1..1480e17 100644
--- a/src/bot/master.rs
+++ b/src/bot/master.rs
@@ -200,10 +200,9 @@ impl MasterBot {
self.spawn_bot_for(who).await;
}
}
- MusicBotMessage::ChannelAdded(_) => {
- // TODO Only subscribe to one channel
+ MusicBotMessage::ChannelAdded(id) => {
let mut cteamspeak = self.teamspeak.clone();
- cteamspeak.subscribe_all().await;
+ cteamspeak.subscribe(id).await;
}
MusicBotMessage::ClientAdded(id) => {
let mut cteamspeak = self.teamspeak.clone();
diff --git a/src/bot/music.rs b/src/bot/music.rs
index e8ed33a..19b1c3f 100644
--- a/src/bot/music.rs
+++ b/src/bot/music.rs
@@ -295,10 +295,10 @@ impl MusicBot {
}
}
- async fn subscribe_all(&self) {
+ async fn subscribe(&self, id: ChannelId) {
if let Some(ts) = &self.teamspeak {
let mut ts = ts.clone();
- ts.subscribe_all().await;
+ ts.subscribe(id).await;
}
}
@@ -446,9 +446,8 @@ impl MusicBot {
let old_channel = client.channel;
self.on_client_left_channel(old_channel).await;
}
- MusicBotMessage::ChannelAdded(_) => {
- // TODO Only subscribe to one channel
- self.subscribe_all().await;
+ MusicBotMessage::ChannelAdded(id) => {
+ self.subscribe(id).await;
}
MusicBotMessage::StateChange(state) => {
self.on_state(state).await?;
diff --git a/src/teamspeak/mod.rs b/src/teamspeak/mod.rs
index 4d7c840..beb3f44 100644
--- a/src/teamspeak/mod.rs
+++ b/src/teamspeak/mod.rs
@@ -300,16 +300,18 @@ impl TeamSpeakConnection {
.unwrap()
}
- pub async fn subscribe_all(&mut self) {
+ pub async fn subscribe(&mut self, id: ChannelId) {
self.handle
.with_connection(move |mut conn| {
- if let Err(e) = conn
- .get_state()
- .expect("can get state")
- .server
- .set_subscribed(true)
- .send(&mut conn)
- {
+ let channel = match conn.get_state().expect("can get state").channels.get(&id) {
+ Some(c) => c,
+ None => {
+ error!("Failed to find channel to subscribe to");
+ return;
+ }
+ };
+
+ if let Err(e) = channel.set_subscribed(true).send(&mut conn) {
error!("Failed to send subscribe packet: {}", e);
}
})