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 //! This module consists of endpoints to handle callbacks
mod decrypt; crate::export_handlers!(decrypt, delete, delete_message, get, get_menu);
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;
use crate::errors::InvalidCommand; use crate::errors::InvalidCommand;
use base64::{engine::general_purpose::STANDARD_NO_PAD as B64_ENGINE, Engine as _}; 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 //! This module consists of endpoints to handle commands
mod add_account; crate::export_handlers!(
mod cancel; add_account,
mod delete; cancel,
mod delete_all; delete,
mod export; delete_all,
mod gen_password; export,
mod get_account; gen_password,
mod get_accounts; get_account,
mod help; get_accounts,
mod import; help,
mod menu; import,
mod set_master_pass; menu,
mod start; set_master_pass,
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;
use teloxide::macros::BotCommands; 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 //! This module consists of endpoints to handle the state
mod generic; 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; 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}; 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 crate::prelude::*;
use teloxide::dispatching::dialogue::InMemStorage; use teloxide::dispatching::dialogue::InMemStorage;