aboutsummaryrefslogtreecommitdiffstats
path: root/src/bot/master.rs
diff options
context:
space:
mode:
authorJokler <jokler@protonmail.com>2020-02-02 19:50:33 +0100
committerJokler <jokler@protonmail.com>2020-02-22 23:20:10 +0100
commit2831c2b60cb61a14c7efee4ab5c0389eb3ad5469 (patch)
tree835f1abad6e234f6d74d4be999f690709954be89 /src/bot/master.rs
parentca4c0158f417b87f04313053a3f656f2de4e803b (diff)
downloadpokebot-2831c2b60cb61a14c7efee4ab5c0389eb3ad5469.tar.gz
pokebot-2831c2b60cb61a14c7efee4ab5c0389eb3ad5469.zip
Add a very basic template using available info
Diffstat (limited to 'src/bot/master.rs')
-rw-r--r--src/bot/master.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bot/master.rs b/src/bot/master.rs
index bc38cca..10a7572 100644
--- a/src/bot/master.rs
+++ b/src/bot/master.rs
@@ -213,14 +213,24 @@ impl MasterBot {
Ok(())
}
- pub fn names(&self) -> Vec<String> {
+ pub fn bot_datas(&self) -> Vec<crate::web_server::BotData> {
let music_bots = self.music_bots.read().unwrap();
- music_bots
- .connected_bots
- .iter()
- .map(|(_, b)| b.name().to_owned())
- .collect()
+ let len = music_bots.connected_bots.len();
+ let mut result = Vec::with_capacity(len);
+ for (name, bot) in &music_bots.connected_bots {
+ let bot_data = crate::web_server::BotData {
+ name: name.clone(),
+ state: bot.state(),
+ volume: bot.volume(),
+ currently_playing: bot.currently_playing(),
+ playlist: bot.playlist_to_vec(),
+ };
+
+ result.push(bot_data);
+ }
+
+ result
}
pub fn quit(&self, reason: String) {