2023-07-25 16:09:34 +00:00
|
|
|
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?;
|
|
|
|
}
|
|
|
|
|
2023-07-25 21:52:12 +00:00
|
|
|
let markup = spawn_blocking(|| menu_markup_sync(names)).await?;
|
2023-07-25 16:09:34 +00:00
|
|
|
bot.send_message(msg.chat.id, "Choose your account")
|
|
|
|
.reply_markup(markup)
|
|
|
|
.await?;
|
|
|
|
Ok(())
|
|
|
|
}
|