Added cancel command to allow the user to know that they can use it

This commit is contained in:
StNicolay 2023-05-07 20:11:52 +03:00
parent 3a9c038090
commit 00bbb7e960
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D
3 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,6 @@
use teloxide::{adaptors::Throttle, prelude::*};
pub async fn cancel(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
bot.send_message(msg.chat.id, "Nothing to cancel").await?;
Ok(())
}

View File

@ -1,4 +1,5 @@
mod add_account; mod add_account;
mod cancel;
mod default; mod default;
mod delete; mod delete;
mod delete_all; mod delete_all;
@ -11,6 +12,7 @@ mod import;
mod set_master_pass; mod set_master_pass;
pub use add_account::add_account; pub use add_account::add_account;
pub use cancel::cancel;
pub use default::default; pub use default::default;
pub use delete::delete; pub use delete::delete;
pub use delete_all::delete_all; pub use delete_all::delete_all;

View File

@ -63,6 +63,8 @@ enum Command {
Import, Import,
#[command(description = "generates 10 secure passwords")] #[command(description = "generates 10 secure passwords")]
GenPassword, GenPassword,
#[command(description = "cancels the current action")]
Cancel,
} }
#[derive(Default, Clone)] #[derive(Default, Clone)]
@ -88,6 +90,7 @@ pub fn get_dispatcher(
.branch(case![Command::Help].endpoint(commands::help)) .branch(case![Command::Help].endpoint(commands::help))
.branch(case![Command::SetMasterPass].endpoint(commands::set_master_pass)) .branch(case![Command::SetMasterPass].endpoint(commands::set_master_pass))
.branch(case![Command::GenPassword].endpoint(commands::gen_password)) .branch(case![Command::GenPassword].endpoint(commands::gen_password))
.branch(case![Command::Cancel].endpoint(commands::cancel))
.branch(master_password_check::get_handler()) .branch(master_password_check::get_handler())
.branch(case![Command::AddAccount].endpoint(commands::add_account)) .branch(case![Command::AddAccount].endpoint(commands::add_account))
.branch(case![Command::GetAccount].endpoint(commands::get_account)) .branch(case![Command::GetAccount].endpoint(commands::get_account))