aboutsummaryrefslogtreecommitdiffstats
path: root/src/bot/master.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bot/master.rs')
-rw-r--r--src/bot/master.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/bot/master.rs b/src/bot/master.rs
index 7612c68..dad2bed 100644
--- a/src/bot/master.rs
+++ b/src/bot/master.rs
@@ -88,11 +88,19 @@ impl MasterBot {
let msg_loop = async move {
'outer: loop {
while let Some(msg) = rx.recv().await {
- if let MusicBotMessage::Quit(reason) = msg {
- cbot.teamspeak.disconnect(&reason);
- break 'outer;
+ match msg {
+ MusicBotMessage::Quit(reason) => {
+ cbot.teamspeak.disconnect(&reason);
+ break 'outer;
+ }
+ MusicBotMessage::ClientDisconnected { id, .. } => {
+ if id == cbot.my_id() {
+ // TODO Reconnect since quit was not called
+ break 'outer;
+ }
+ },
+ _ => cbot.on_message(msg).await.unwrap(),
}
- cbot.on_message(msg).await.unwrap();
}
}
};
@@ -204,6 +212,10 @@ impl MasterBot {
Ok(())
}
+ fn my_id(&self) -> ClientId {
+ self.teamspeak.my_id()
+ }
+
pub fn bot_data(&self, name: String) -> Option<crate::web_server::BotData> {
let music_bots = self.music_bots.read().unwrap();
let bot = music_bots.connected_bots.get(&name)?;