Added ask_name_handler

This commit is contained in:
2023-07-16 22:54:01 +03:00
parent 255f29bfad
commit 010ac62a74
4 changed files with 37 additions and 57 deletions

View File

@ -25,31 +25,4 @@ handler!(
State::GetMasterPass,
get_master_pass
);
/// Handles /delete command
pub async fn delete(
bot: Throttle<Bot>,
msg: Message,
dialogue: MainDialogue,
db: DatabaseConnection,
) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let markup = account_markup(user_id, &db).await?;
if markup.keyboard.is_empty() {
bot.send_message(msg.chat.id, "No accounts found")
.reply_markup(deletion_markup())
.await?;
return Ok(());
}
let previous = bot
.send_message(msg.chat.id, "Send the name of the account to delete")
.reply_markup(markup)
.await?;
dialogue
.update(State::GetExistingName(Handler::new(
get_account_name,
&previous,
)))
.await?;
Ok(())
}
ask_name_handler!(pub delete(), "Send the name of the account to delete", get_account_name);

View File

@ -32,31 +32,4 @@ async fn get_master_pass(
}
handler!(get_account_name(name:String), "Send master password", State::GetMasterPass, get_master_pass);
/// Handles /get_account command
pub async fn get_account(
bot: Throttle<Bot>,
msg: Message,
dialogue: MainDialogue,
db: DatabaseConnection,
) -> crate::Result<()> {
let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
let markup = account_markup(user_id, &db).await?;
if markup.keyboard.is_empty() {
bot.send_message(msg.chat.id, "No accounts found")
.reply_markup(deletion_markup())
.await?;
return Ok(());
}
let previous = bot
.send_message(msg.chat.id, "Send the name of the account to get")
.reply_markup(markup)
.await?;
dialogue
.update(State::GetExistingName(Handler::new(
get_account_name,
&previous,
)))
.await?;
Ok(())
}
ask_name_handler!(pub get_account(), "Send the name of the account to get", get_account_name);