feat(macro): rename macro_rule and move to separate module
This commit is contained in:
parent
7214caeed5
commit
b728eafd4b
13
src/main.rs
13
src/main.rs
|
@ -41,15 +41,6 @@ fn logs() {
|
|||
);
|
||||
}
|
||||
|
||||
macro_rules! append_command {
|
||||
($branch:expr, $($command:expr), *) => {
|
||||
$($branch
|
||||
.message
|
||||
.register($command)
|
||||
.filter(Command::one(stringify!($command)));
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
@ -75,8 +66,8 @@ async fn main() {
|
|||
let mut admin_commands = Router::new("admin_commands");
|
||||
let mut default_commands = Router::new("default_commands");
|
||||
|
||||
append_command!(default_commands, help, privacy);
|
||||
append_command!(admin_commands, unmute, mute, ban);
|
||||
create_handler!(default_commands, info_commands_endpoint, help, privacy);
|
||||
create_handler!(admin_commands, admin_command_endpoint, mute, unmute, ban);
|
||||
|
||||
admin_commands
|
||||
.message
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#[macro_export]
|
||||
macro_rules! create_handler {
|
||||
($branch:expr, $command:expr) => {
|
||||
$($branch
|
||||
.message
|
||||
.register($command)
|
||||
.filter(Command::one(stringify!($command)));
|
||||
)*
|
||||
};
|
||||
($branch:expr, $command:expr, $($endpoint:expr), *) => {
|
||||
$branch
|
||||
.message
|
||||
.register($command)
|
||||
.filter(Command::many([$(stringify!($endpoint)),*]));
|
||||
};
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
pub mod create_handler;
|
Loading…
Reference in New Issue