Added start command

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

View File

@ -10,6 +10,7 @@ mod get_accounts;
mod help;
mod import;
mod set_master_pass;
mod start;
pub use add_account::add_account;
pub use cancel::cancel;
@ -23,3 +24,4 @@ pub use get_accounts::get_accounts;
pub use help::help;
pub use import::import;
pub use set_master_pass::set_master_pass;
pub use start::start;

View File

@ -0,0 +1,11 @@
use teloxide::{adaptors::Throttle, prelude::*};
pub async fn start(bot: Throttle<Bot>, msg: Message) -> crate::Result<()> {
bot.send_message(
msg.chat.id,
"Hi! This bot can be used to store the passwords securely. \
Use /help command to get the list of commands",
)
.await?;
Ok(())
}

View File

@ -43,6 +43,8 @@ type PackagedHandler<T> = Arc<Mutex<Option<Handler<T>>>>;
description = "These commands are supported:"
)]
enum Command {
#[command(description = "displays the welcome message")]
Start,
#[command(description = "displays this text")]
Help,
#[command(description = "sets the master password")]
@ -87,6 +89,7 @@ pub fn get_dispatcher(
let bot = Bot::new(token).throttle(Limits::default());
let command_handler = filter_command::<Command, _>()
.branch(case![Command::Start].endpoint(commands::start))
.branch(case![Command::Help].endpoint(commands::help))
.branch(case![Command::SetMasterPass].endpoint(commands::set_master_pass))
.branch(case![Command::GenPassword].endpoint(commands::gen_password))