send message when queue is empty

This commit is contained in:
Oleg Sobolev 2024-03-26 10:09:26 +07:00
parent d6b2b54d13
commit 959f954d9d

View file

@ -68,15 +68,17 @@ impl TelegramBot {
} }
Command::List => { Command::List => {
let tracks = player.lock().unwrap().list_tracks(); let tracks = player.lock().unwrap().list_tracks();
bot.send_message( let message: String;
msg.chat.id, if tracks.is_empty() {
tracks message = String::from("The queue is empty.");
} else {
message = tracks
.iter() .iter()
.map(|t| t.path.to_str().unwrap()) .map(|t| t.path.to_str().unwrap())
.collect::<Vec<&str>>() .collect::<Vec<&str>>()
.join("\n"), .join("\n");
) }
.await?; bot.send_message(msg.chat.id, message).await?;
} }
}; };
Ok(()) Ok(())