]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/modcmd.c
helpfile improvements
[irc/evilnet/x3.git] / src / modcmd.c
index bc0d365a397868072b2f0fc005207873c1d5d2f7..89122fe0d51cc2a2c54e5480e93d74e335752eb3 100644 (file)
@@ -1,7 +1,7 @@
 /* modcmd.c - Generalized module command support
  * Copyright 2002-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
-//#include "arch-version.h"
+#include "../ChangeLog.X3"
 #include "chanserv.h"
 #include "conf.h"
 #include "modcmd.h"
@@ -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." },
@@ -146,18 +147,18 @@ static struct modcmd_flag {
     { "channel", MODCMD_REQUIRE_CHANNEL },
     { "chanuser", MODCMD_REQUIRE_CHANUSER },
     { "disabled", MODCMD_DISABLED },
+    { "helping", MODCMD_REQUIRE_HELPING },
     { "ignore_csuspend", MODCMD_IGNORE_CSUSPEND },
     { "joinable", MODCMD_REQUIRE_JOINABLE },
     { "keepbound", MODCMD_KEEP_BOUND },
     { "loghostmask", MODCMD_LOG_HOSTMASK },
-    { "nolog", MODCMD_NO_LOG },
     { "networkhelper", MODCMD_REQUIRE_NETWORK_HELPER },
     { "never_csuspend", MODCMD_NEVER_CSUSPEND },
+    { "nolog", MODCMD_NO_LOG },
     { "oper", MODCMD_REQUIRE_OPER },
     { "qualified", MODCMD_REQUIRE_QUALIFIED },
     { "regchan", MODCMD_REQUIRE_REGCHAN },
     { "supporthelper", MODCMD_REQUIRE_SUPPORT_HELPER },
-    { "helping", MODCMD_REQUIRE_HELPING },
     { "toy", MODCMD_TOY },
     { NULL, 0 }
 };
@@ -546,7 +547,8 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm
         rflags |= ACTION_STAFF;
     }
     if (cmd->min_opserv_level > 0) {
-        if (!oper_has_access(user, bot, cmd->min_opserv_level, !(options & SVCCMD_NOISY))) return 0;
+        if (!oper_has_access(user, bot, cmd->min_opserv_level, !(options & SVCCMD_NOISY)))
+          return 0;
         rflags |= ACTION_STAFF;
     }
     if (cmd->req_account_flags || cmd->deny_account_flags) {
@@ -567,7 +569,7 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm
     /* If it's an override, return a special value. */
     if ((flags & MODCMD_REQUIRE_CHANUSER)
         && (options & SVCCMD_NOISY)
-        && (uData->access > 500)
+        && (!uData || (uData->access > 500))
         && (!(uData = _GetChannelUser(channel->channel_info, user->handle_info, 0, 0))
             || uData->access < cmd->min_channel_access)
         && !(flags & (MODCMD_REQUIRE_STAFF|MODCMD_REQUIRE_HELPING))) {
@@ -720,6 +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_brief(user, service->bot, cmd);
         return 0;
     }
     if (!cmd->command->func) {
@@ -771,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) {
@@ -782,6 +789,41 @@ svccmd_send_help(struct userNode *user, struct userNode *bot, struct svccmd *cmd
     return r;
 }
 
+int
+svccmd_send_help_brief(struct userNode *user, struct userNode *bot, struct svccmd *cmd) {
+    char cmdname[MAXLEN];
+    unsigned int nn;
+    int r;
+    /* Show command name (in bold). */
+    for (nn=0; cmd->name[nn]; nn++)
+        cmdname[nn] = toupper(cmd->name[nn]);
+    cmdname[nn] = 0;
+
+    /* Show the help entry for the underlying command. */
+        /* Lets not show help for a parent command, thats not what
+         * they asked for!
+         * 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.
+         */
+    /* 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;
+}
+
+
 int
 svccmd_send_help_2(struct userNode *user, struct service *service, const char *topic) {
     struct module *module;
@@ -867,10 +909,10 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, char *text, int serv
             irc_notice_user(bot, user, "\001CLIENTINFO CLIENTINFO PING TIME USERINFO VERSION\x01");
         } else if (!irccasecmp(text, "PING")) {
             if (term) {
-                snprintf(response, sizeof(response), "\x01PONG %s\x01", term);
+                snprintf(response, sizeof(response), "\x01PING %s\x01", term);
                 irc_notice_user(bot, user, response);
             } else {
-                irc_notice_user(bot,user, "\x01PONG\x01");
+                irc_notice_user(bot,user, "\x01PING\x01");
             }
         } else if (!irccasecmp(text, "TIME")) {
             struct tm tm;
@@ -882,12 +924,12 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, char *text, int serv
             irc_notice_user(bot, user, response);
         } else if (!irccasecmp(text, "VERSION")) {
             /* This function provides copyright management information
-             * to end users of srvx. You should not alter, disable or
+             * to end users of X3. You should not alter, disable or
              * remove this command or its accessibility to normal IRC
              * users, except to add copyright information pertaining
-             * to changes you make to srvx.
+             * to changes you make to X3.
              */
-            snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, "");
+            snprintf(response, sizeof(response), "\x01VERSION %s\x01", PACKAGE_STRING);
             irc_notice_user(bot, user, response);
         }
         return;
@@ -1479,7 +1521,7 @@ static MODCMD_FUNC(cmd_god) {
 }
 
 static MODCMD_FUNC(cmd_joiner) {
-    char cmdname[80];
+    char cmdname[MAXLEN];
 
     if (argc < 2) {
         int len = sprintf(cmdname, "%s ", cmd->name);
@@ -1685,12 +1727,12 @@ static MODCMD_FUNC(cmd_showcommands) {
             if (flags & MODCMD_REQUIRE_HELPING)
                 access = "helping";
             else if (flags & MODCMD_REQUIRE_STAFF) {
-                switch (flags & MODCMD_REQUIRE_STAFF) {
-                case MODCMD_REQUIRE_OPER: access = "oper"; break;
-                case MODCMD_REQUIRE_OPER | MODCMD_REQUIRE_NETWORK_HELPER:
-                case MODCMD_REQUIRE_NETWORK_HELPER: access = "net.helper"; break;
-                default: access = "staff"; break;
-                }
+                if (flags & MODCMD_REQUIRE_OPER)
+                    access = "oper";
+                else if (flags & MODCMD_REQUIRE_NETWORK_HELPER)
+                    access = "net.helper";
+                else
+                    access = "staff";
             } else
                 access = strtab(svccmd->min_channel_access);
             tbl.contents[ii+1][1+show_opserv_level] = access;
@@ -1745,7 +1787,7 @@ static MODCMD_FUNC(cmd_service_add) {
         reply("MCMSG_ALREADY_SERVICE", bot->nick);
         return 0;
     }
-    bot = AddService(nick, desc, hostname);
+    bot = AddService(nick, NULL, desc, hostname);
     service_register(bot);
     reply("MCMSG_NEW_SERVICE", bot->nick);
     return 1;
@@ -1861,13 +1903,17 @@ static MODCMD_FUNC(cmd_dump_messages) {
 
 static MODCMD_FUNC(cmd_version) {
     /* This function provides copyright management information to end
-     * users of srvx. You should not alter, disable or remove this
+     * users of X3. You should not alter, disable or remove this
      * command or its accessibility to normal IRC users, except to add
-     * copyright information pertaining to changes you make to srvx.
+     * copyright information pertaining to changes you make to X3.
      */
-    send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__".\nCopyright 2000-2004 srvx Development Team.\nThe srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net.");
-    if ((argc > 1) && !irccasecmp(argv[1], "arch"))
-        send_message_type(4, user, cmd->parent->bot, "%s", "");
+    send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b (Based on srvx 1.3), Built: "__DATE__", "__TIME__".");
+    send_message_type(4, user, cmd->parent->bot, "("CVS_VERSION")");
+    send_message_type(4, user, cmd->parent->bot, "Copyright 2000-2005 srvx Development Team.");
+    send_message_type(4, user, cmd->parent->bot, "Copyright 2004-2005 X3 Development Team.");
+    send_message_type(4, user, cmd->parent->bot, "The srvx 1.3 Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.");
+    send_message_type(4, user, cmd->parent->bot, "The X3 Development Team includes Alex Schumann, Reed Loden, Neil Spierling.");
+    send_message_type(4, user, cmd->parent->bot, "The X3 Development Team can be reached at http://sf.net/projects/x2serv/ or in #evilnet on irc.afternet.org.");
     return 1;
 }
 
@@ -2064,7 +2110,7 @@ modcmd_load_bots(struct dict *db, int default_nick) {
         hostname = database_get_data(rd->d.object, "hostname", RECDB_QSTRING);
         if (desc) {
             if (!svc)
-                svc = service_register(AddService(nick, desc, hostname));
+                svc = service_register(AddService(nick, NULL, desc, hostname));
             else if (hostname)
                 strcpy(svc->bot->hostname, hostname);
             desc = database_get_data(rd->d.object, "trigger", RECDB_QSTRING);
@@ -2325,6 +2371,7 @@ create_default_binds(void) {
             service_make_alias(service, "addcoowner", "*chanserv.adduser", "$1", "coowner", NULL);
             service_make_alias(service, "addmanager", "*chanserv.adduser", "$1", "manager", NULL);
             service_make_alias(service, "addop", "*chanserv.adduser", "$1", "op", NULL);
+            service_make_alias(service, "addhop", "*chanserv.adduser", "$1", "halfop", NULL);
             service_make_alias(service, "addpeon", "*chanserv.adduser", "$1", "peon", NULL);
             service_make_alias(service, "delowner", "*chanserv.deluser", "owner", "$1", NULL);
             service_make_alias(service, "delcoowner", "*chanserv.deluser", "coowner", "$1", NULL);