]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/modcmd.c
helpfile improvements
[irc/evilnet/x3.git] / src / modcmd.c
index b2964e8a4c9e250932944a2171c9e78c02974d41..89122fe0d51cc2a2c54e5480e93d74e335752eb3 100644 (file)
@@ -55,6 +55,7 @@ static const struct message_entry msgtab[] = {
     { "MCMSG_NO_CHANNEL_BEFORE", "You may not give a channel name before this command." },
     { "MCMSG_NO_PLUS_CHANNEL", "You may not use a +channel with this command." },
     { "MCMSG_COMMAND_ALIASES", "%s is an alias for: %s" },
+/*    { "MCMSG_HELP_COMMAND_ALIAS_FOR", "$bALIAS FOR:$b %s" },*/
     { "MCMSG_HELP_COMMAND_ALIAS", "$uAlias for:$u %s" },
     { "MCMSG_COMMAND_BINDING", "%s is a binding of: %s" },
     { "MCMSG_ALIAS_ERROR", "Error in alias expansion for %s; check the error log for details." },
@@ -721,7 +722,7 @@ svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNo
     }
     if (argc < cmd->command->min_argc) {
         send_message(user, service->bot, "MSG_MISSING_PARAMS", cmd->name);
-        svccmd_send_help_breef(user, service->bot, cmd);
+        svccmd_send_help_brief(user, service->bot, cmd);
         return 0;
     }
     if (!cmd->command->func) {
@@ -773,7 +774,11 @@ svccmd_send_help(struct userNode *user, struct userNode *bot, struct svccmd *cmd
          * return send_help(user, bot, cmd->command->parent->helpfile, cmd->command->name);
          * TODO: We actually DO want to show the parent IF there is no other help.
          */
-    r = send_help(user, bot, cmd->command->parent->helpfile, cmd->name);
+    r =        send_help(user, bot, cmd->command->parent->helpfile, cmd->name);
+    if(cmd->command->name && strcasecmp(cmd->command->name, cmd->name))
+    {
+        send_message(user, bot, "MCMSG_HELP_COMMAND_ALIAS", cmd->command->name);
+    }
 
     /* If it's an alias, show what it's an alias for. */
     if (cmd->alias.used) {
@@ -785,7 +790,7 @@ svccmd_send_help(struct userNode *user, struct userNode *bot, struct svccmd *cmd
 }
 
 int
-svccmd_send_help_breef(struct userNode *user, struct userNode *bot, struct svccmd *cmd) {
+svccmd_send_help_brief(struct userNode *user, struct userNode *bot, struct svccmd *cmd) {
     char cmdname[MAXLEN];
     unsigned int nn;
     int r;
@@ -800,7 +805,20 @@ svccmd_send_help_breef(struct userNode *user, struct userNode *bot, struct svccm
          * return send_help(user, bot, cmd->command->parent->helpfile, cmd->command->name);
          * TODO: We actually DO want to show the parent IF there is no other help.
          */
-    r = send_help_breef(user, bot, cmd->command->parent->helpfile, cmd->name);
+    /* If it's an alias, show what it's an alias for. */
+    if (cmd->alias.used) {
+        char alias_text[MAXLEN];
+        unsplit_string((char**)cmd->alias.list, cmd->alias.used, alias_text);
+        send_message(user, bot, "MCMSG_COMMAND_ALIASES", cmd->name, cmd->command->name);
+    }
+    r = send_help_brief(user, bot, cmd->command->parent->helpfile, cmd->name);
+    if(!r) {
+        if(cmd->command->name)
+        {
+           send_message(user, bot, "MCMSG_COMMAND_ALIASES", cmd->name, cmd->command->name);
+           r = send_help_brief(user, bot, cmd->command->parent->helpfile, cmd->command->name);
+        }
+    }
 
     return r;
 }