Created markups.rs

This commit is contained in:
2023-05-04 21:15:41 +03:00
parent 925df8a5e5
commit 332356a95b
4 changed files with 29 additions and 16 deletions

View File

@ -1,13 +1,9 @@
use crate::entity::{account, prelude::Account};
use crate::handlers::{utils::package_handler, MainDialogue, State};
use futures::TryStreamExt;
use sea_orm::prelude::*;
use teloxide::{
adaptors::Throttle,
prelude::*,
types::ParseMode,
types::{KeyboardButton, KeyboardMarkup},
use crate::{
entity::{account, prelude::Account},
handlers::{markups, utils::package_handler, MainDialogue, State},
};
use sea_orm::prelude::*;
use teloxide::{adaptors::Throttle, prelude::*, types::ParseMode};
use tokio::task::spawn_blocking;
async fn get_master_pass(
@ -64,13 +60,7 @@ pub async fn get_account(
dialogue: MainDialogue,
db: DatabaseConnection,
) -> crate::Result<()> {
let account_names: Vec<Vec<KeyboardButton>> = Account::get_names(msg.from().unwrap().id.0, &db)
.await?
.map_ok(|account| KeyboardButton::new(account))
.try_chunks(3)
.try_collect()
.await?;
let markup = KeyboardMarkup::new(account_names).resize_keyboard(true);
let markup = markups::account_markup(msg.from().unwrap().id.0, &db).await?;
let previous = bot
.send_message(msg.chat.id, "Send account name")
.reply_markup(markup)