diff options
| author | Catlinman <contact@catlinman.com> | 2020-07-25 13:30:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-25 13:30:18 +0200 |
| commit | 681950517d511d1c4b8e465f9b9758c027ecd6bf (patch) | |
| tree | 8563101e5415d552846bfc69c0dd851ff8e35391 /src/bot/music.rs | |
| parent | 3575ac579cdcc5a9fa3ffec84952a634d1d7deaf (diff) | |
| parent | 4e2e4afbef3eb8a4fdd6c08c8d531090825e6eb6 (diff) | |
| download | pokebot-681950517d511d1c4b8e465f9b9758c027ecd6bf.tar.gz pokebot-681950517d511d1c4b8e465f9b9758c027ecd6bf.zip | |
Merge pull request #57 from Mavulp/fix-subscribe
Diffstat (limited to 'src/bot/music.rs')
| -rw-r--r-- | src/bot/music.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/bot/music.rs b/src/bot/music.rs index 96cc383..14a73f9 100644 --- a/src/bot/music.rs +++ b/src/bot/music.rs @@ -13,10 +13,10 @@ use tsclientlib::{data, ChannelId, ClientId, ConnectOptions, Identity, Invoker, use crate::audio_player::{AudioPlayer, AudioPlayerError, PollResult}; use crate::command::Command; +use crate::command::VolumeChange; use crate::playlist::Playlist; use crate::teamspeak as ts; use crate::youtube_dl::AudioMetadata; -use crate::command::VolumeChange; use ts::TeamSpeakConnection; #[derive(Debug)] @@ -53,6 +53,7 @@ pub enum MusicBotMessage { client: ClientId, old_channel: ChannelId, }, + ChannelCreated(ChannelId), ClientDisconnected { id: ClientId, client: data::Client, @@ -175,7 +176,11 @@ impl MusicBot { format!("") }; - self.send_message(&format!("Playing {} {}", ts::underline(&metadata.title), duration)); + self.send_message(&format!( + "Playing {} {}", + ts::underline(&metadata.title), + duration + )); self.set_description(&format!("Currently playing '{}'", metadata.title)); self.player.reset().unwrap(); self.player.set_metadata(metadata).unwrap(); @@ -273,6 +278,10 @@ impl MusicBot { self.with_teamspeak(|ts| ts.set_description(desc)); } + fn subscribe_all(&self) { + self.with_teamspeak(|ts| ts.subscribe_all()); + } + async fn on_text(&self, message: Message) -> Result<(), AudioPlayerError> { let msg = message.text; if msg.starts_with("!") { @@ -310,7 +319,8 @@ impl MusicBot { self.add_audio(url.to_string(), invoker.name).await; } Command::Search { query } => { - self.add_audio(format!("ytsearch:{}", query.join(" ")), invoker.name).await; + self.add_audio(format!("ytsearch:{}", query.join(" ")), invoker.name) + .await; } Command::Pause => { self.player.pause()?; @@ -415,6 +425,10 @@ impl MusicBot { let old_channel = client.channel; self.on_client_left_channel(old_channel); } + MusicBotMessage::ChannelCreated(_) => { + // TODO Only subscribe to one channel + self.subscribe_all(); + } MusicBotMessage::StateChange(state) => { self.on_state(state)?; } |
