Added menu endpoints

This commit is contained in:
2023-07-25 19:09:34 +03:00
parent 64a5435dc3
commit 96c7d2e37e
6 changed files with 75 additions and 2 deletions

23
src/commands/menu.rs Normal file
View File

@@ -0,0 +1,23 @@
use crate::prelude::*;
use tokio::task::spawn_blocking;
pub async fn menu(bot: Throttle<Bot>, msg: Message, db: DatabaseConnection) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let names: Vec<String> = Account::get_names(user_id, &db)
.await?
.try_collect()
.await?;
if names.is_empty() {
bot.send_message(msg.chat.id, "You don't have any accounts")
.reply_markup(deletion_markup())
.await?;
}
let markup = spawn_blocking(|| menu_markup(names)).await?;
bot.send_message(msg.chat.id, "Choose your account")
.reply_markup(markup)
.await?;
Ok(())
}