License update
[srvx.git] / src / opserv.c
index 8c2a356d91cee7a3b5e8203c217f65b93be08014..6d31e784884a2ff8a3ab276e87a6c63fe8bbedcf 100644 (file)
@@ -1,11 +1,12 @@
 /* opserv.c - IRC Operator assistance service
  * Copyright 2000-2004 srvx Development Team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of srvx.
+ *
+ * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.  Important limitations are
- * listed in the COPYING file that accompanies this software.
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,7 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, email srvx-maintainers@srvx.net.
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #include "conf.h"
@@ -160,6 +162,7 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_RAW_PARSE_ERROR", "Error parsing raw line (not dumping to uplink)." },
     { "OSMSG_COLLIDED_NICK", "Now temporarily holding nick $b%s$b." },
     { "OSMSG_RESERVED_NICK", "Now reserving nick $b%s$b." },
+    { "OSMSG_NICK_UNRESERVED", "Nick $b%s$b is no longer reserved." },
     { "OSMSG_NOT_RESERVED", "Nick $b%s$b is not reserved." },
     { "OSMSG_ILLEGAL_REASON", "This channel is illegal." },
     { "OSMSG_ILLEGAL_KILL_REASON", "Joined an illegal modeless channel - do not repeat." },
@@ -240,7 +243,7 @@ static const struct message_entry msgtab[] = {
     { "OSMSG_CHANINFO_TOPIC_UNKNOWN", "Topic: (none / not gathered)" },
     { "OSMSG_CHANINFO_BAN_COUNT", "Bans (%d):" },
     { "OSMSG_CHANINFO_BAN", "%%s by %%s (%a %b %d %H:%M:%S %Y)" },
-    { "OSMSG_CHANINFO_MANY_USERS", "%d users (\"/msg $s %s %s users\" for the list)" },
+    { "OSMSG_CHANINFO_MANY_USERS", "%d users (\"/msg $S %s %s users\" for the list)" },
     { "OSMSG_CHANINFO_USER_COUNT", "Users (%d):" },
     { "OSMSG_CSEARCH_CHANNEL_INFO", "%s [%d users] %s %s" },
     { NULL, NULL }
@@ -442,7 +445,7 @@ static MODCMD_FUNC(cmd_chaninfo)
        for (n = 0; n < channel->banlist.used; n++) {
            ban = channel->banlist.list[n];
            strftime(buffer, sizeof(buffer), fmt, localtime(&ban->set));
-           reply(buffer, ban->ban, ban->who);
+           send_message_type(4, user, cmd->parent->bot, buffer, ban->ban, ban->who);
        }
     }
     if ((argc < 2) && (channel->members.used >= 50)) {
@@ -1039,7 +1042,7 @@ static MODCMD_FUNC(cmd_kickbanall)
         change->args[1].mode = MODE_BAN;
         change->args[1].hostmask = "*!*@*";
     } else {
-        change = mod_chanmode_alloc(2);
+        change = mod_chanmode_alloc(1);
         change->args[0].mode = MODE_BAN;
         change->args[0].hostmask = "*!*@*";
     }
@@ -1110,7 +1113,7 @@ static MODCMD_FUNC(cmd_op)
             continue;
         if (!(mn =  GetUserMode(channel, victim)))
             continue;
-        if (!(mn->modes & MODE_CHANOP))
+        if (mn->modes & MODE_CHANOP)
             continue;
         change->args[count].mode = MODE_CHANOP;
         change->args[count++].member = mn;
@@ -1802,7 +1805,7 @@ opserv_shutdown_channel(struct chanNode *channel, const char *reason)
         struct modeNode *mNode = channel->members.list[--nn];
         if (IsService(mNode->user))
             continue;
-        KickChannelUser(mNode->user, channel, opserv, reason);
+        KickChannelUser(mNode->user, channel, opserv, user_find_message(mNode->user, reason));
     }
     timeq_add(now + opserv_conf.purge_lock_delay, opserv_part_channel, channel);
 }
@@ -1826,6 +1829,12 @@ opserv_channel_check(struct chanNode *newchan)
     newchan->bad_channel = opserv_bad_channel(newchan->name);
 }
 
+static void
+opserv_channel_delete(struct chanNode *chan)
+{
+    timeq_del(0, opserv_part_channel, chan, TIMEQ_IGNORE_WHEN);
+}
+
 static int
 opserv_join_check(struct modeNode *mNode)
 {
@@ -1843,7 +1852,7 @@ opserv_join_check(struct modeNode *mNode)
         if (channel->name[0] != '#')
             DelUser(user, opserv, 1, "OSMSG_ILLEGAL_KILL_REASON");
         else if (!GetUserMode(channel, opserv))
-            opserv_shutdown_channel(channel, user_find_message(user, "OSMSG_ILLEGAL_REASON"));
+            opserv_shutdown_channel(channel, "OSMSG_ILLEGAL_REASON");
         else {
             send_message(user, opserv, "OSMSG_ILLEGAL_CHANNEL", channel->name);
             msg = user_find_message(user, "OSMSG_ILLEGAL_REASON");
@@ -1875,7 +1884,7 @@ opserv_join_check(struct modeNode *mNode)
                 change.modes_set |= MODE_MODERATED;
             if (change.modes_set || change.argc)
                 mod_chanmode_announce(opserv, channel, &change);
-            send_channel_notice(channel, opserv, "OSMSG_FLOOD_MODERATE");
+            send_target_message(0, channel->name, opserv, "OSMSG_FLOOD_MODERATE");
             opserv_alert("Warning: Possible join flood in %s (currently %d users; channel moderated).", channel->name, channel->members.used);
         } else {
             opserv_alert("Warning: Possible join flood in %s (currently %d users).", channel->name, channel->members.used);
@@ -2358,9 +2367,9 @@ opserv_define_func(const char *name, modcmd_func_t *func, int min_level, int req
     case 2: iflags = MODCMD_REQUIRE_CHANNEL; break;
     }
     if (flags) {
-        return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, "flags", flags, NULL);
+        return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, "flags", flags, "flags", "+oper", NULL);
     } else {
-        return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, NULL);
+        return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, "flags", "+oper", NULL);
     }
 }
 
@@ -4112,6 +4121,7 @@ init_opserv(const char *nick)
     reg_nick_change_func(opserv_alert_check_nick);
     reg_del_user_func(opserv_user_cleanup);
     reg_new_channel_func(opserv_channel_check);
+    reg_del_channel_func(opserv_channel_delete);
     reg_join_func(opserv_join_check);
     reg_auth_func(opserv_staff_alert);