Added export handler macro

This commit is contained in:
StNicolay 2023-07-29 16:07:53 +03:00
parent 42088e69fe
commit b415277769
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D
4 changed files with 36 additions and 50 deletions

View File

@ -1,16 +1,6 @@
//! This module consists of endpoints to handle callbacks
mod decrypt;
mod delete;
mod delete_message;
mod get;
mod get_menu;
pub use decrypt::decrypt;
pub use delete::delete;
pub use delete_message::delete_message;
pub use get::get;
pub use get_menu::get_menu;
crate::export_handlers!(decrypt, delete, delete_message, get, get_menu);
use crate::errors::InvalidCommand;
use base64::{engine::general_purpose::STANDARD_NO_PAD as B64_ENGINE, Engine as _};

View File

@ -1,32 +1,20 @@
//! This module consists of endpoints to handle commands
mod add_account;
mod cancel;
mod delete;
mod delete_all;
mod export;
mod gen_password;
mod get_account;
mod get_accounts;
mod help;
mod import;
mod menu;
mod set_master_pass;
mod start;
pub use add_account::add_account;
pub use cancel::cancel;
pub use delete::delete;
pub use delete_all::delete_all;
pub use export::export;
pub use gen_password::gen_password;
pub use get_account::get_account;
pub use get_accounts::get_accounts;
pub use help::help;
pub use import::import;
pub use menu::menu;
pub use set_master_pass::set_master_pass;
pub use start::start;
crate::export_handlers!(
add_account,
cancel,
delete,
delete_all,
export,
gen_password,
get_account,
get_accounts,
help,
import,
menu,
set_master_pass,
start
);
use teloxide::macros::BotCommands;

View File

@ -71,3 +71,14 @@ macro_rules! simple_state_handler {
}
};
}
#[macro_export]
macro_rules! export_handlers {
($($name: ident),*) => {
$(
mod $name;
pub use $name::$name;
)
*
};
}

View File

@ -1,22 +1,19 @@
//! This module consists of endpoints to handle the state
mod generic;
mod get_login;
mod get_master_pass;
mod get_new_master_pass;
mod get_new_name;
mod get_password;
mod get_user;
mod handler;
pub use get_login::get_login;
pub use get_master_pass::get_master_pass;
pub use get_new_master_pass::get_new_master_pass;
pub use get_new_name::get_new_name;
pub use get_password::get_password;
pub use get_user::get_user;
pub use handler::{Handler, MessageIds, PackagedHandler};
crate::export_handlers!(
get_login,
get_master_pass,
get_new_master_pass,
get_new_name,
get_password,
get_user
);
use crate::prelude::*;
use teloxide::dispatching::dialogue::InMemStorage;