introduce unreg_privmsg_func, fix minor autoinvite issue, alter account-finding on...
[srvx.git] / src / chanserv.c
index c6137c85d55ddb74438c31fc256e24d1949343c7..75f7ee24b47faa4f1a30350314b6b89c29bbdac7 100644 (file)
@@ -54,6 +54,7 @@
 #define KEY_NETWORK_HELPER_EPITHET  "network_helper_epithet"
 #define KEY_SUPPORT_HELPER_EPITHET  "support_helper_epithet"
 #define KEY_NODELETE_LEVEL      "nodelete_level"
+#define KEY_MAX_USERINFO_LENGTH "max_userinfo_length"
 
 /* ChanServ database */
 #define KEY_CHANNELS           "channels"
@@ -236,7 +237,7 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_MODE_LOCKED", "Modes conflicting with $b%s$b are not allowed in %s." },
     { "CSMSG_CANNOT_SET", "That setting is above your current level, so you cannot change it." },
     { "CSMSG_OWNER_DEFAULTS", "You must have access 500 in %s to reset it to the default options." },
-    { "CSMSG_CONFIRM_DEFAULTS", "To reset %s's settings to the defaults, you muse use 'set defaults %s'." },
+    { "CSMSG_CONFIRM_DEFAULTS", "To reset %s's settings to the defaults, you must use 'set defaults %s'." },
     { "CSMSG_SETTINGS_DEFAULTED", "All settings for %s have been reset to default values." },
     { "CSMSG_BAD_SETLEVEL", "You cannot change any setting to above your level." },
     { "CSMSG_BAD_GIVEVOICE", "You cannot change GiveVoice to above GiveOps (%d)." },
@@ -296,10 +297,13 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_CTCPREACTION_LONGBAN", "Long timed ban on disallowed CTCPs" },
 
     { "CSMSG_INVITED_USER", "Invited $b%s$b to join %s." },
-    { "CSMSG_INVITING_YOU", "$b%s$b invites you to join %s%s%s" },
-    { "CSMSG_ALREADY_PRESENT", "%s is $balready in %s$b." },
+    { "CSMSG_INVITING_YOU_REASON", "$b%s$b invites you to join %s: %s" },
+    { "CSMSG_INVITING_YOU", "$b%s$b invites you to join %s." },
+    { "CSMSG_ALREADY_PRESENT", "%s is already in $b%s$b." },
     { "CSMSG_YOU_ALREADY_PRESENT", "You are already in $b%s$b." },
     { "CSMSG_LOW_CHANNEL_ACCESS", "You lack sufficient access in %s to use this command." },
+    { "CSMSG_INFOLINE_TOO_LONG", "Your infoline may not exceed %u characters." },
+    { "CSMSG_BAD_INFOLINE", "You may not use the character \\%03o in your infoline." },
 
     { "CSMSG_KICK_DONE", "Kicked $b%s$b from %s." },
     { "CSMSG_NO_BANS", "No channel bans found on $b%s$b." },
@@ -395,6 +399,7 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_NETWORK_SERVERS", "$bServers:             $b%i" },
     { "CSMSG_NETWORK_USERS",   "$bTotal Users:         $b%i" },
     { "CSMSG_NETWORK_BANS",    "$bTotal Ban Count:     $b%i" },
+    { "CSMSG_NETWORK_CHANUSERS", "$bTotal User Count:    $b%i" },
     { "CSMSG_NETWORK_OPERS",   "$bIRC Operators:       $b%i" },
     { "CSMSG_NETWORK_CHANNELS","$bRegistered Channels: $b%i" },
     { "CSMSG_SERVICES_UPTIME", "$bServices Uptime:     $b%s" },
@@ -426,9 +431,9 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_WUT_RESPONSE", "wut" },
     { "CSMSG_BAD_NUMBER", "$b%s$b is an invalid number.  Please use a number greater than 1 with this command." },
     { "CSMSG_BAD_DIE_FORMAT", "I do not understand $b%s$b.  Please use either a single number or standard 4d6+3 format." },
-    { "CSMSG_BAD_DICE_COUNT", "%d is too many dice.  Please use at most %d." },
-    { "CSMSG_DICE_ROLL", "The total is $b%d$b from rolling %dd%d+%d." },
-    { "CSMSG_DIE_ROLL", "A $b%d$b shows on the %d-sided die." },
+    { "CSMSG_BAD_DICE_COUNT", "%lu is too many dice.  Please use at most %lu." },
+    { "CSMSG_DICE_ROLL", "The total is $b%lu$b from rolling %lud%lu+%lu." },
+    { "CSMSG_DIE_ROLL", "A $b%lu$b shows on the %lu-sided die." },
     { "CSMSG_HUGGLES_HIM", "\001ACTION huggles %s\001" },
     { "CSMSG_HUGGLES_YOU", "\001ACTION huggles you\001" },
 
@@ -491,6 +496,7 @@ static struct
     unsigned int        max_owned;
     unsigned int       max_chan_users;
     unsigned int       max_chan_bans;
+    unsigned int        max_userinfo_length;
 
     struct string_list  *set_shows;
     struct string_list  *eightball;
@@ -641,7 +647,7 @@ user_level_from_name(const char *name, unsigned short clamp_level)
 {
     unsigned int level = 0, ii;
     if(isdigit(name[0]))
-        level = atoi(name);
+        level = strtoul(name, NULL, 10);
     else for(ii = 0; (ii < ArrayLength(accessLevels)) && !level; ++ii)
         if(!irccasecmp(name, accessLevels[ii].name))
             level = accessLevels[ii].level;
@@ -1333,7 +1339,7 @@ expire_channels(UNUSED_ARG(void *data))
     struct userData *user;
     char delay[INTERVALLEN], reason[INTERVALLEN + 64];
 
-    intervalString(delay, chanserv_conf.channel_expire_delay);
+    intervalString(delay, chanserv_conf.channel_expire_delay, NULL);
     sprintf(reason, "Channel registration automatically expired after %s of disuse.", delay);
 
     for(channel = channelList; channel; channel = next)
@@ -1538,7 +1544,7 @@ static CHANSERV_FUNC(cmd_noregister)
         {
             dnr = iter_data(it);
             if(dnr->set)
-                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
             else
                 reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
             matches++;
@@ -1547,7 +1553,7 @@ static CHANSERV_FUNC(cmd_noregister)
         {
             dnr = iter_data(it);
             if(dnr->set)
-                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
             else
                 reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
             matches++;
@@ -1556,7 +1562,7 @@ static CHANSERV_FUNC(cmd_noregister)
         {
             dnr = iter_data(it);
             if(dnr->set)
-                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
             else
                 reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
             matches++;
@@ -2380,7 +2386,7 @@ cmd_trim_bans(struct userNode *user, struct chanNode *channel, unsigned long dur
         count++;
     }
 
-    intervalString(interval, duration);
+    intervalString(interval, duration, user->handle_info);
     send_message(user, chanserv, "CSMSG_TRIMMED_BANS", count, channel->name, interval);
     return 1;
 }
@@ -2428,7 +2434,7 @@ cmd_trim_users(struct userNode *user, struct chanNode *channel, unsigned short m
         min_access = 1;
         max_access = UL_OWNER;
     }
-    send_message(user, chanserv, "CSMSG_TRIMMED_USERS", count, min_access, max_access, channel->name, intervalString(interval, duration));
+    send_message(user, chanserv, "CSMSG_TRIMMED_USERS", count, min_access, max_access, channel->name, intervalString(interval, duration, user->handle_info));
     return 1;
 }
 
@@ -2503,11 +2509,17 @@ static CHANSERV_FUNC(cmd_up)
         change.args[0].mode = MODE_CHANOP;
         errmsg = "CSMSG_ALREADY_OPPED";
     }
-    else
+    else if(uData->access >= channel->channel_info->lvlOpts[lvlGiveVoice])
     {
         change.args[0].mode = MODE_VOICE;
         errmsg = "CSMSG_ALREADY_VOICED";
     }
+    else
+    {
+        if(argc)
+            reply("CSMSG_NO_ACCESS");
+        return 0;
+    }
     change.args[0].mode &= ~change.args[0].member->modes;
     if(!change.args[0].mode)
     {
@@ -2825,7 +2837,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c
                             /* automated kickban */
                         }
                        else if(duration)
-                           reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration));
+                           reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration, user->handle_info));
                        else
                            reply("CSMSG_BAN_ADDED", name, channel->name);
 
@@ -2932,7 +2944,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c
     else if(action & ACTION_ADD_BAN)
     {
        if(duration)
-           reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration));
+           reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration, user->handle_info));
        else
            reply("CSMSG_BAN_ADDED", name, channel->name);
     }
@@ -3144,9 +3156,9 @@ static CHANSERV_FUNC(cmd_open)
 
 static CHANSERV_FUNC(cmd_myaccess)
 {
+    static struct string_buffer sbuf;
     struct handle_info *target_handle;
     struct userData *uData;
-    const char *chanName;
 
     if(argc < 2)
         target_handle = user->handle_info;
@@ -3175,11 +3187,27 @@ static CHANSERV_FUNC(cmd_myaccess)
            && (target_handle != user->handle_info)
            && !GetTrueChannelAccess(cData, user->handle_info))
             continue;
-        chanName = cData->channel->name;
+        sbuf.used = 0;
+        string_buffer_append_printf(&sbuf, "[%s (%d", cData->channel->name, uData->access);
+        if(uData->flags != USER_AUTO_OP)
+            string_buffer_append(&sbuf, ',');
+        if(IsUserSuspended(uData))
+            string_buffer_append(&sbuf, 's');
+        if(IsUserAutoOp(uData))
+        {
+            if(uData->access >= cData->lvlOpts[lvlGiveOps])
+                string_buffer_append(&sbuf, 'o');
+            else if(uData->access >= cData->lvlOpts[lvlGiveVoice])
+                string_buffer_append(&sbuf, 'v');
+        }
+        if(IsUserAutoInvite(uData) && (uData->access >= cData->lvlOpts[lvlInviteMe]))
+            string_buffer_append(&sbuf, 'i');
         if(uData->info)
-            send_message_type(4, user, cmd->parent->bot, "[%s (%d)] %s", chanName, uData->access, uData->info);
+            string_buffer_append_printf(&sbuf, ")] %s", uData->info);
         else
-            send_message_type(4, user, cmd->parent->bot, "[%s (%d)]", chanName, uData->access);
+            string_buffer_append_string(&sbuf, ")]");
+        string_buffer_append(&sbuf, '\0');
+        send_message_type(4, user, cmd->parent->bot, sbuf.list);
     }
 
     return 1;
@@ -3448,7 +3476,7 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg
         else if(!uData->seen)
             ary[2] = "Never";
         else
-            ary[2] = intervalString(seen, now - uData->seen);
+            ary[2] = intervalString(seen, now - uData->seen, user->handle_info);
         ary[2] = strdup(ary[2]);
         if(IsUserSuspended(uData))
             ary[3] = "Suspended";
@@ -3555,12 +3583,12 @@ static CHANSERV_FUNC(cmd_bans)
        if(!timed)
            expires = "";
        else if(ban->expires)
-           expires = intervalString(e_buffer, ban->expires - now);
+           expires = intervalString(e_buffer, ban->expires - now, user->handle_info);
        else
            expires = msg_never;
 
        if(ban->triggered)
-           triggered = intervalString(t_buffer, now - ban->triggered);
+           triggered = intervalString(t_buffer, now - ban->triggered, user->handle_info);
        else
            triggered = msg_never;
 
@@ -3743,8 +3771,13 @@ static CHANSERV_FUNC(cmd_invite)
 
     if(user != invite)
     {
-       char *reason = (argc > 2) ? unsplit_string(argv + 2, argc - 2, NULL) : "";
-       send_message(invite, chanserv, "CSMSG_INVITING_YOU", user->nick, channel->name, (argc > 2) ? ": " : ".", reason);
+        if(argc > 2)
+        {
+            char *reason = unsplit_string(argv + 2, argc - 2, NULL);
+            send_message(invite, chanserv, "CSMSG_INVITING_YOU_REASON", user->nick, channel->name, reason);
+        }
+        else
+            send_message(invite, chanserv, "CSMSG_INVITING_YOU", user->nick, channel->name);
     }
     irc_invite(chanserv, invite, channel);
     if(argc > 1)
@@ -3789,34 +3822,34 @@ show_suspension_info(struct svccmd *cmd, struct userNode *user, struct suspended
         reply("CSMSG_CHANNEL_SUSPENDED_0", suspended->suspender, suspended->reason);
         break;
     case 1: /* no issue time, expires in future */
-        intervalString(buf1, suspended->expires-now);
+        intervalString(buf1, suspended->expires-now, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_1", suspended->suspender, buf1, suspended->reason);
         break;
     case 2: /* no issue time, expired */
-        intervalString(buf1, now-suspended->expires);
+        intervalString(buf1, now-suspended->expires, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_2", suspended->suspender, buf1, suspended->reason);
         break;
     case 3: /* no issue time, revoked */
-        intervalString(buf1, now-suspended->revoked);
+        intervalString(buf1, now-suspended->revoked, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_3", suspended->suspender, buf1, suspended->reason);
         break;
     case 4: /* issue time set, indefinite expiration */
-        intervalString(buf1, now-suspended->issued);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_4", buf1, suspended->suspender, suspended->reason);
         break;
     case 5: /* issue time set, expires in future */
-        intervalString(buf1, now-suspended->issued);
-        intervalString(buf2, suspended->expires-now);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
+        intervalString(buf2, suspended->expires-now, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_5", buf1, suspended->suspender, buf2, suspended->reason);
         break;
     case 6: /* issue time set, expired */
-        intervalString(buf1, now-suspended->issued);
-        intervalString(buf2, now-suspended->expires);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
+        intervalString(buf2, now-suspended->expires, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_6", buf1, suspended->suspender, buf2, suspended->reason);
         break;
     case 7: /* issue time set, revoked */
-        intervalString(buf1, now-suspended->issued);
-        intervalString(buf2, now-suspended->revoked);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
+        intervalString(buf2, now-suspended->revoked, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_7", buf1, suspended->suspender, buf2, suspended->reason);
         break;
     default:
@@ -3864,8 +3897,8 @@ static CHANSERV_FUNC(cmd_info)
             reply("CSMSG_CHANNEL_OWNER", owner->handle->handle);
     reply("CSMSG_CHANNEL_USERS", cData->userCount);
     reply("CSMSG_CHANNEL_BANS", cData->banCount);
-    reply("CSMSG_CHANNEL_VISITED", intervalString(buffer, now - cData->visited));
-    reply("CSMSG_CHANNEL_REGISTERED", intervalString(buffer, now - cData->registered));
+    reply("CSMSG_CHANNEL_VISITED", intervalString(buffer, now - cData->visited, user->handle_info));
+    reply("CSMSG_CHANNEL_REGISTERED", intervalString(buffer, now - cData->registered, user->handle_info));
 
     privileged = IsStaff(user);
     if(((uData && uData->access >= UL_COOWNER) || privileged) && cData->registrar)
@@ -3901,9 +3934,9 @@ static CHANSERV_FUNC(cmd_netinfo)
     reply("CSMSG_NETWORK_OPERS", curr_opers.used);
     reply("CSMSG_NETWORK_CHANNELS", registered_channels);
     reply("CSMSG_NETWORK_BANS", banCount);
-    reply("CSMSG_CHANNEL_USERS", userCount);
-    reply("CSMSG_SERVICES_UPTIME", intervalString(interval, time(NULL) - boot_time));
-    reply("CSMSG_BURST_LENGTH",intervalString(interval, burst_length));
+    reply("CSMSG_NETWORK_CHANUSERS", userCount);
+    reply("CSMSG_SERVICES_UPTIME", intervalString(interval, time(NULL) - boot_time, user->handle_info));
+    reply("CSMSG_BURST_LENGTH", intervalString(interval, burst_length, user->handle_info));
     return 1;
 }
 
@@ -4109,7 +4142,7 @@ static CHANSERV_FUNC(cmd_seen)
     if(uData->present)
        reply("CSMSG_USER_PRESENT", handle->handle);
     else if(uData->seen)
-        reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen));
+        reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen, user->handle_info));
     else
         reply("CSMSG_NEVER_SEEN", handle->handle, channel->name);
 
@@ -4132,7 +4165,7 @@ static MODCMD_FUNC(cmd_names)
         targData = GetTrueChannelAccess(channel->channel_info, targ->handle_info);
         if(!targData)
             continue;
-        if(pos + strlen(targ->nick) + strlen(targ->handle_info->handle) + 6 > sizeof(buf))
+        if(pos + strlen(targ->nick) + strlen(targ->handle_info->handle) + 8 > sizeof(buf))
         {
             buf[pos] = 0;
             reply("CSMSG_CHANNEL_NAMES", channel->name, buf);
@@ -4291,12 +4324,14 @@ static CHANSERV_FUNC(cmd_events)
     unsigned int matches, limit;
 
     limit = (argc > 1) ? atoi(argv[1]) : 10;
-    if(limit < 1 || limit > 200) limit = 10;
+    if(limit < 1 || limit > 200)
+        limit = 10;
 
     memset(&discrim, 0, sizeof(discrim));
     discrim.masks.bot = chanserv;
     discrim.masks.channel_name = channel->name;
-    if(argc > 2) discrim.masks.command = argv[2];
+    if(argc > 2)
+        discrim.masks.command = argv[2];
     discrim.limit = limit;
     discrim.max_time = INT_MAX;
     discrim.severities = 1 << LOG_COMMAND;
@@ -4661,7 +4696,7 @@ static CHANSERV_FUNC(cmd_unvisited)
             limit = atoi(argv[2]);
     }
 
-    intervalString(buffer, interval);
+    intervalString(buffer, interval, user->handle_info);
     reply("CSMSG_UNVISITED_HEADER", limit, buffer);
 
     for(cData = channelList; cData && matches < limit; cData = cData->next)
@@ -4669,7 +4704,7 @@ static CHANSERV_FUNC(cmd_unvisited)
        if((now - cData->visited) < interval)
             continue;
 
-       intervalString(buffer, now - cData->visited);
+       intervalString(buffer, now - cData->visited, user->handle_info);
        reply("CSMSG_UNVISITED_DATA", cData->channel->name, buffer);
        matches++;
     }
@@ -5236,7 +5271,19 @@ static MODCMD_FUNC(user_opt_info)
 
     if(argc > 1)
     {
+        size_t bp;
         infoline = unsplit_string(argv + 1, argc - 1, NULL);
+        if(strlen(infoline) > chanserv_conf.max_userinfo_length)
+        {
+            reply("CSMSG_INFOLINE_TOO_LONG", chanserv_conf.max_userinfo_length);
+            return 0;
+        }
+        bp = strcspn(infoline, "\001");
+        if(infoline[bp])
+        {
+            reply("CSMSG_BAD_INFOLINE", infoline[bp]);
+            return 0;
+        }
         if(uData->info)
             free(uData->info);
         if(infoline[0] == '*' && infoline[1] == 0)
@@ -5867,8 +5914,8 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
             if(!IsUserSuspended(channel)
                && IsUserAutoInvite(channel)
                && (channel->access >= channel->channel->lvlOpts[lvlInviteMe])
-               && (cn->modes & (MODE_KEY | MODE_INVITEONLY))
-               && !self->burst)
+               && !self->burst
+              && !user->uplink->burst)
                 irc_invite(chanserv, user, cn);
             continue;
         }
@@ -5956,7 +6003,10 @@ handle_part(struct userNode *user, struct chanNode *channel, UNUSED_ARG(const ch
     }
 
     if((uData = GetTrueChannelAccess(cData, user->handle_info)))
+    {
        scan_user_presence(uData, user);
+        uData->seen = now;
+    }
 
     if(IsHelping(user) && IsSupportHelper(user))
     {
@@ -5977,6 +6027,8 @@ handle_part(struct userNode *user, struct chanNode *channel, UNUSED_ARG(const ch
 static void
 handle_kick(struct userNode *kicker, struct userNode *victim, struct chanNode *channel)
 {
+    struct userData *uData;
+
     if(!channel->channel_info || !kicker || IsService(kicker)
        || (kicker == victim) || IsSuspended(channel->channel_info)
        || (kicker->handle_info && kicker->handle_info == victim->handle_info))
@@ -5987,6 +6039,9 @@ handle_kick(struct userNode *kicker, struct userNode *victim, struct chanNode *c
         const char *reason = user_find_message(kicker, "CSMSG_USER_PROTECTED");
        KickChannelUser(kicker, channel, chanserv, reason);
     }
+
+    if((uData = GetTrueChannelAccess(channel->channel_info, victim->handle_info)))
+        uData->seen = now;
 }
 
 static int
@@ -6067,7 +6122,7 @@ handle_mode(struct chanNode *channel, struct userNode *user, const struct mod_ch
             bounce->args[bnc].member = change->args[ii].member;
             bnc++;
         }
-        else if(change->args[ii].mode & MODE_BAN)
+        else if((change->args[ii].mode & (MODE_REMOVE | MODE_BAN)) == MODE_BAN)
         {
             const char *ban = change->args[ii].hostmask;
             if(!bad_channel_ban(channel, user, ban, NULL, NULL))
@@ -6239,6 +6294,8 @@ chanserv_conf_read(void)
     chanserv_conf.max_chan_users = str ? atoi(str) : 512;
     str = database_get_data(conf_node, KEY_MAX_CHAN_BANS, RECDB_QSTRING);
     chanserv_conf.max_chan_bans = str ? atoi(str) : 512;
+    str = database_get_data(conf_node, KEY_MAX_USERINFO_LENGTH, RECDB_QSTRING);
+    chanserv_conf.max_userinfo_length = str ? atoi(str) : 400;
     str = database_get_data(conf_node, KEY_NICK, RECDB_QSTRING);
     if(chanserv && str)
         NickChange(chanserv, str, 0);
@@ -7123,8 +7180,8 @@ init_chanserv(const char *nick)
     dict_set_free_data(note_types, chanserv_deref_note_type);
     if(nick)
     {
-        chanserv = AddService(nick, "Channel Services");
-        service_register(chanserv, '!');
+        chanserv = AddService(nick, "Channel Services", NULL);
+        service_register(chanserv)->trigger = '!';
         reg_chanmsg_func('\001', chanserv, chanserv_ctcp_check);
     }
     saxdb_register("ChanServ", chanserv_saxdb_read, chanserv_saxdb_write);