Code cleanup
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
use crate::prelude::*;
|
||||
use tokio::task::spawn_blocking;
|
||||
|
||||
#[inline]
|
||||
pub async fn menu(bot: Throttle<Bot>, msg: Message, db: Pool) -> crate::Result<()> {
|
||||
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
|
||||
|
||||
let names: Vec<String> = Account::get_names(user_id, &db).try_collect().await?;
|
||||
let markup = menu_markup("get", user_id, &db).await?;
|
||||
|
||||
if names.is_empty() {
|
||||
if markup.inline_keyboard.is_empty() {
|
||||
bot.send_message(msg.chat.id, "You don't have any accounts")
|
||||
.reply_markup(deletion_markup())
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let markup = spawn_blocking(|| menu_markup_sync("get", names)).await?;
|
||||
bot.send_message(msg.chat.id, "Choose your account")
|
||||
.reply_markup(markup)
|
||||
.await?;
|
||||
|
Reference in New Issue
Block a user