diff --git a/src/core/commands.c b/src/core/commands.c index 44a40ce..f68278a 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -132,19 +132,40 @@ static int command_status_user_not_found(struct hub_info* hub, struct hub_user* const char* command_get_syntax(struct commands_handler* handler) { static char args[128]; + int optional = 0; size_t n = 0; args[0] = 0; if (handler->args) { for (n = 0; n < strlen(handler->args); n++) { + // detect optionals + if (handler->args[n] == '?') + { + optional = 1; + continue; + } + if (n > 0) strcat(args, " "); + + if (optional) + { + strcat(args, "["); + } + switch (handler->args[n]) { case 'n': strcat(args, ""); break; case 'c': strcat(args, ""); break; case 'a': strcat(args, ""); break; case 'm': strcat(args, ""); break; + case 'i': strcat(args, ""); break; + } + + if (optional) + { + strcat(args, "]"); + optional = 0; } } } @@ -606,7 +627,7 @@ static struct commands_handler command_handlers[] = { #endif { "getip", 5, "n", cred_operator, command_getip, "Show IP address for a user" }, { "help", 4, 0, cred_guest, command_help, "Show this help message." }, - { "history", 7, 0, cred_guest, command_history, "Show the last chat messages." }, + { "history", 7, "?i",cred_guest, command_history, "Show the last chat messages." }, { "kick", 4, "n", cred_operator, command_kick, "Kick a user" }, { "log", 3, 0, cred_operator, command_log, "Display log" }, { "motd", 4, 0, cred_guest, command_motd, "Show the message of the day" }, diff --git a/src/core/config.xml b/src/core/config.xml index 2b8b0b8..0dd22ae 100644 --- a/src/core/config.xml +++ b/src/core/config.xml @@ -211,6 +211,17 @@ 0.3.0 + + +