]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/modcmd.c
Fix for <trigger>shoot telling you to use .roulette instead of <trigger>roulette
[irc/evilnet/x3.git] / src / modcmd.c
index b790a26bd448e6b6fffdc1bd9519848fb4881047..3a9c2cba17510b80716362419824f4ea61aedbe4 100644 (file)
@@ -37,7 +37,7 @@ static struct dict *modules;
 static struct dict *services;
 static struct pending_template *pending_templates;
 static struct module *modcmd_module;
-static struct modcmd *bind_command, *help_command, *version_command;
+static struct modcmd *bind_command, *help_command, *version_command, *credits_command;
 static const struct message_entry msgtab[] = {
     { "MCMSG_BARE_FLAG", "Flag %.*s must be preceded by a + or -." },
     { "MCMSG_UNKNOWN_FLAG", "Unknown module flag %.*s." },
@@ -652,7 +652,7 @@ int
 svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNode *channel, unsigned int argc, char *argv[], unsigned int server_qualified) {
     extern struct userNode *chanserv;
     struct svccmd *cmd;
-    unsigned int cmd_arg, perms, flags, options, result;
+    unsigned int cmd_arg, perms, flags, options;
     char channel_name[CHANNELLEN+1];
 
     options = (server_qualified ? SVCCMD_QUALIFIED : 0) | SVCCMD_DEBIT | SVCCMD_NOISY;
@@ -765,13 +765,11 @@ svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNo
         safestrncpy(channel_name, channel->name, sizeof(channel_name));
     else
         channel_name[0] = 0;
-    if (!(result = cmd->command->func(user, channel, argc, argv, cmd)))
+    if (!cmd->command->func(user, channel, argc, argv, cmd))
         return 0;
     if (!(flags & MODCMD_NO_LOG)) {
         enum log_severity slvl;
-        if (result & CMD_LOG_OVERRIDE)
-            slvl = LOG_OVERRIDE;
-        else if ((perms & ACTION_STAFF) || (result & CMD_LOG_STAFF))
+        if (perms & ACTION_STAFF)
             slvl = LOG_STAFF;
         else if (perms & ACTION_OVERRIDE)
             slvl = LOG_OVERRIDE;
@@ -907,10 +905,9 @@ svccmd_send_help(struct userNode *user, struct service *service, const char *top
 }
 
 static int
-svccmd_invoke(struct userNode *user, struct service *service, struct chanNode *channel, const char *text, int server_qualified) {
+svccmd_invoke(struct userNode *user, struct service *service, struct chanNode *channel, char *text, int server_qualified) {
     unsigned int argc;
     char *argv[MAXNUMPARAMS];
-    char tmpline[MAXLEN];
 
     if (!*text)
         return 0;
@@ -928,13 +925,34 @@ svccmd_invoke(struct userNode *user, struct service *service, struct chanNode *c
             return 0;
         }
     }
-    safestrncpy(tmpline, text, sizeof(tmpline));
-    argc = split_line(tmpline, false, ArrayLength(argv), argv);
+    argc = split_line(text, false, ArrayLength(argv), argv);
     return argc ? svccmd_invoke_argv(user, service, channel, argc, argv, server_qualified) : 0;
 }
 
+char *cvs_verstring() {
+  static char verstring[MAXLEN] = { 0 };
+  
+  if(!*verstring) {
+    char *svn = NULL, *svnver = NULL, *svndate = NULL, *v = 0, ver[MAXLEN];
+    int vc = 0;
+
+    strcpy(ver, CVS_VERSION);
+    for (svn = x3_strtok(&v, ver, " "); svn;
+         svn = x3_strtok(&v, 0, " ")) {
+        if (vc == 2)
+            svnver = svn;
+        else if (vc == 3)
+            svndate = svn;
+        vc++;
+    }
+    sprintf(verstring, "%s %s", svnver, svndate);
+  }
+  return verstring;
+}
+
+
 void
-modcmd_privmsg(struct userNode *user, struct userNode *bot, const char *text, int server_qualified) {
+modcmd_privmsg(struct userNode *user, struct userNode *bot, char *text, int server_qualified) {
     struct service *service;
 
     if (!(service = dict_find(services, bot->nick, NULL))) {
@@ -981,13 +999,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")) {
-            /* This function provides copyright management information
-             * 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 X3.
-             */
-            snprintf(response, sizeof(response), "\x01VERSION %s\x01", PACKAGE_STRING);
+            snprintf(response, sizeof(response), "\x01VERSION %s+[%s]\x01", PACKAGE_STRING, cvs_verstring());
             irc_notice_user(bot, user, response);
         } else if (!irccasecmp(text, "GENDER")) {
              snprintf(response, sizeof(response), "\x01GENDER ummm im still deciding\x01");
@@ -1002,7 +1014,7 @@ modcmd_privmsg(struct userNode *user, struct userNode *bot, const char *text, in
 }
 
 void
-modcmd_chanmsg(struct userNode *user, struct chanNode *chan, const char *text, struct userNode *bot) {
+modcmd_chanmsg(struct userNode *user, struct chanNode *chan, char *text, struct userNode *bot) {
     struct service *service;
     if (!(service = dict_find(services, bot->nick, NULL))) return;
     svccmd_invoke(user, service, chan, text, 0);
@@ -1870,7 +1882,7 @@ static MODCMD_FUNC(cmd_service_add) {
         reply("MCMSG_ALREADY_SERVICE", bot->nick);
         return 0;
     }
-    bot = AddLocalUser(nick, nick, hostname, desc, NULL);
+    bot = AddService(nick, NULL, desc, hostname);
     service_register(bot);
     reply("MCMSG_NEW_SERVICE", bot->nick);
     return 1;
@@ -1985,27 +1997,18 @@ static MODCMD_FUNC(cmd_dump_messages) {
 }
 
 static MODCMD_FUNC(cmd_version) {
-    /* This function provides copyright management information 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 X3.
-     */
-
-    char *svn = NULL, *svnver = NULL, *svndate = NULL, *v = 0, ver[MAXLEN];
-    int vc = 0;
-
-    strcpy(ver, CVS_VERSION);
-    for (svn = x3_strtok(&v, ver, " "); svn;
-         svn = x3_strtok(&v, 0, " ")) {
-        if (vc == 2)
-            svnver = svn;
-        else if (vc == 3)
-            svndate = svn;
-        vc++;
-    }
+    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, "See $bCREDITS$b for more information.");
+    return 1;
+}
 
-    send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s %s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", svnver, svndate);
-    send_message_type(4, user, cmd->parent->bot, "$b$b");
+/* This function provides copyright management information 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 X3.
+ */
+static MODCMD_FUNC(cmd_credits) {
+    send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE"$b is based on srvx");
     send_message_type(4, user, cmd->parent->bot, "Copyright 2000-2007 srvx Development Team.");
     send_message_type(4, user, cmd->parent->bot, "Copyright 2004-2007 X3 Development Team.");
     send_message_type(4, user, cmd->parent->bot, "This software is OSI Certified Open Source Software.");
@@ -2016,7 +2019,7 @@ static MODCMD_FUNC(cmd_version) {
     send_message_type(4, user, cmd->parent->bot, "The X3 Development Team can be reached at http://evilnet.sourceforge.net or in #evilnet on irc.afternet.org.");
     send_message_type(4, user, cmd->parent->bot, "$b$b");
     send_message_type(4, user, cmd->parent->bot, "Thanks goes to ThiefMaster, Joe Hansche (joeatrr), Martijn Smit (wasted), and to any other people who have contributed to X3.");
-    send_message_type(4, user, cmd->parent->bot, "This program is free software; see COPYING in the distribution.");
+    send_message_type(4, user, cmd->parent->bot, "This program is free software; see COPYING in the distribution files.");
 
     return 1;
 }
@@ -2029,19 +2032,6 @@ static MODCMD_FUNC(cmd_rebindall) {
     return 1;
 }
 
-static MODCMD_FUNC(cmd_tell) {
-    struct userNode *target;
-    char *msg;
-
-    target = GetUserH(argv[1]);
-    msg = unsplit_string(argv + 2, argc - 2, NULL);
-    if (!target) {
-        reply("MSG_NOT_TARGET_NAME");
-        return 0;
-    }
-    send_message_type(MSG_TYPE_NOXLATE, target, cmd->parent->bot, "%s", msg);
-    return 1;
-}
 
 void
 modcmd_nick_change(struct userNode *user, const char *old_nick) {
@@ -2235,7 +2225,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(AddLocalUser(nick, nick, hostname, desc, NULL));
+                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);
@@ -2284,9 +2274,9 @@ modcmd_init(void) {
     modcmd_register(modcmd_module, "service privileged", cmd_service_privileged, 2, 0, "flags", "+oper", NULL);
     modcmd_register(modcmd_module, "service remove", cmd_service_remove, 2, 0, "flags", "+oper", NULL);
     modcmd_register(modcmd_module, "dumpmessages", cmd_dump_messages, 1, 0, "oper_level", "1000", NULL);
-    modcmd_register(modcmd_module, "tell", cmd_tell, 3, 0, "flags", "+oper", NULL);
     modcmd_register(modcmd_module, "rebindall", cmd_rebindall, 0, MODCMD_KEEP_BOUND, "oper_level", "800", NULL);
     version_command = modcmd_register(modcmd_module, "version", cmd_version, 1, 0, NULL);
+    credits_command = modcmd_register(modcmd_module, "credits", cmd_credits, 1, 0, NULL);
     message_register_table(msgtab);
 }
 
@@ -2492,6 +2482,7 @@ create_default_binds(int rebind) {
         /* Bind the help and version commands to this service */
         service_bind_modcmd(service, help_command, help_command->name);
         service_bind_modcmd(service, version_command, version_command->name);
+        service_bind_modcmd(service, credits_command, credits_command->name);
 
         /* Now some silly hax.. (aliases that most people want) */
         if (!irccasecmp(def_binds[ii].svcname, "ChanServ")) {
@@ -2502,11 +2493,13 @@ create_default_binds(int rebind) {
             service_make_alias(service, "addop", "*chanserv.adduser", "$1", "op", "$2", NULL);
             service_make_alias(service, "addhop", "*chanserv.adduser", "$1", "halfop", "$2", NULL);
             service_make_alias(service, "addpeon", "*chanserv.adduser", "$1", "peon", "$2", NULL);
+            service_make_alias(service, "addpal", "*chanserv.adduser", "$1", "pal", "$2", NULL);
             service_make_alias(service, "delowner", "*chanserv.deluser", "owner", "$1", NULL);
             service_make_alias(service, "delcoowner", "*chanserv.deluser", "coowner", "$1", NULL);
             service_make_alias(service, "delmanager", "*chanserv.deluser", "manager", "$1", NULL);
             service_make_alias(service, "delop", "*chanserv.deluser", "op", "$1", NULL);
             service_make_alias(service, "delpeon", "*chanserv.deluser", "peon", "$1", NULL);
+            service_make_alias(service, "delpal", "*chanserv.deluser", "pal", "$1", NULL);
             service_make_alias(service, "llist", "*chanserv.lamers", "$1",  NULL);
             service_make_alias(service, "command", "*modcmd.command", NULL);
             service_make_alias(service, "god", "*modcmd.god", NULL);