]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/modcmd.c
testing again
[irc/evilnet/x3.git] / src / modcmd.c
index 4103a3c302effb15fda7ea0bf9e8f92a7134f128..dfd9ed967ab9095a8f15cb2d5ec94c0e08bb9bc9 100644 (file)
@@ -26,6 +26,7 @@
 #include "opserv.h"
 #include "saxdb.h"
 #include "timeq.h"
+#include "version.h"
 
 
 struct pending_template {
@@ -596,9 +597,10 @@ svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cm
 static int
 svccmd_expand_alias(struct svccmd *cmd, struct userNode *user, unsigned int old_argc, char *old_argv[], char *new_argv[]) {
     unsigned int ii, new_argc;
-    char *arg;
+    char *arg, *altarg;
 
     for (ii=new_argc=0; ii<cmd->alias.used; ++ii) {
+        altarg = NULL;
         arg = cmd->alias.list[ii];
         if (arg[0] != '$') {
             new_argv[new_argc++] = arg;
@@ -613,6 +615,19 @@ svccmd_expand_alias(struct svccmd *cmd, struct userNode *user, unsigned int old_
             lbound = strtoul(arg+1, &end_num, 10);
             switch (end_num[0]) {
             case 0: ubound = lbound; break;
+            case 'a':
+                altarg = (user && user->handle_info) ? user->handle_info->handle : "(account)";
+                break;
+            case 'n':
+                altarg = user ? user->nick : "(nick)";
+                break;
+            case 'm':
+#ifdef WITH_PROTOCOL_P10
+                altarg = user ? user->numeric : "(numnick)";
+#else
+                altarg = "(This ircd protocol has no numnicks!)";
+#endif
+                break;
             case '-':
                 if (end_num[1] == 0) {
                     ubound = old_argc - 1;
@@ -626,6 +641,22 @@ svccmd_expand_alias(struct svccmd *cmd, struct userNode *user, unsigned int old_
                 log_module(MAIN_LOG, LOG_ERROR, "Alias expansion parse error in %s (near %s; %s.%s arg %d).", arg, end_num, cmd->parent->bot->nick, cmd->name, ii);
                 return 0;
             }
+            if (altarg != NULL) {
+                if (end_num[1] != 0) {
+                    if ((end_num[1] == '-') && (end_num[2] == 0))
+                        ubound = old_argc - 1;
+                    else if ((end_num[1] == '-') && (isdigit(end_num[2])))
+                        ubound = strtoul(end_num+2, NULL, 10);
+                    else {
+                        log_module(MAIN_LOG, LOG_ERROR, "Alias expansion parse error in %s (near %s; %s.%s arg %d).", arg, end_num, cmd->parent->bot->nick, cmd->name, ii);
+                        return 0;
+                    }
+                } else {
+                    ubound = lbound;
+                }
+                if (lbound >= old_argc)
+                    new_argv[new_argc++] = altarg;
+            }
             if (ubound >= old_argc)
                 ubound = old_argc - 1;
             if (lbound < old_argc)
@@ -1016,7 +1047,7 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, const char *text, in
             snprintf(response, sizeof(response), "\x01USERINFO %s\x01", bot->info);
             irc_notice_user(bot, user, response);
         } else if (!irccasecmp(text, "VERSION")) {
-            snprintf(response, sizeof(response), "\x01VERSION %s+[%s]\x01", PACKAGE_STRING, cvs_verstring());
+            snprintf(response, sizeof(response), "\x01VERSION %s+[%s]\x01", PACKAGE_STRING, cvs_version);
             irc_notice_user(bot, user, response);
         } else if (!irccasecmp(text, "GENDER")) {
              snprintf(response, sizeof(response), "\x01GENDER ummm im still deciding\x01");
@@ -1126,6 +1157,15 @@ check_alias_args(char *argv[], unsigned int argc) {
             switch (end_num[0]) {
             case 0:
                 continue;
+            case 'a':
+            case 'n':
+            case 'm':
+                if (end_num[1] == 0)
+                    continue;
+                else if (end_num[1] == '-')
+                    end_num++;
+                else
+                    return arg;
             case '-':
                 if (end_num[1] == 0)
                     continue;
@@ -2020,7 +2060,7 @@ static MODCMD_FUNC(cmd_dump_messages) {
 }
 
 static MODCMD_FUNC(cmd_version) {
-    send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", cvs_verstring());
+    send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", cvs_version);
     send_message_type(4, user, cmd->parent->bot, "See $bCREDITS$b for more information.");
     return 1;
 }