]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/chanserv.c
Improved usability of the REGISTER command, in preperation to make it usable by users
[irc/evilnet/x3.git] / src / chanserv.c
index b664ac3173cebc0632741c20f026ec70de9f74f7..ca5e2684147641e9c9bd46598449d44ccf6a8124 100644 (file)
@@ -129,9 +129,11 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_REG_SUCCESS", "You now have ownership of $b%s$b." },
     { "CSMSG_PROXY_SUCCESS", "%s now has ownership of $b%s$b." },
     { "CSMSG_ALREADY_REGGED", "$b%s$b is registered to someone else." },
-    { "CSMSG_MUST_BE_OPPED", "You must be a channel operator in $b%s$b to register it." },
+    { "CSMSG_MUST_BE_OPPED", "You must be a channel operator (+o) in $b%s$b to register it." },
     { "CSMSG_PROXY_FORBIDDEN", "You may not register a channel for someone else." },
-    { "CSMSG_OWN_TOO_MANY", "%s already owns enough channels (at least %d); use FORCE to override." },
+    { "CSMSG_OWN_TOO_MANY", "%s already owns more than the limit of %d channels. Use FORCE to override." },
+    { "CSMSG_YOU_OWN_TOO_MANY", "You already own more than the limit of %d channels. Ask a staff member for help." },
+    { "CSMSG_ANOTHER_SERVICE", "Another service bot is in that channel already. Ask a staff member for help." },
 
 /* Do-not-register channels */
     { "CSMSG_NOT_DNR", "$b%s$b is not a valid channel name or *account." },
@@ -195,13 +197,13 @@ static const struct message_entry msgtab[] = {
     { "CSMSG_TRIMMED_USERS", "Trimmed $b%d users$b with access from %d to %d from the %s user list who were inactive for at least %s." },
     { "CSMSG_INCORRECT_ACCESS", "%s has access $b%s$b, not %s." },
     { "CSMSG_USER_EXISTS", "%s is already on the $b%s$b user list (with %s access)." },
-    { "CSMSG_ADDUSER_PENDING", "I have sent him/her a message letting them know, and if they auth or register soon, i will finish adding them automatically." },
+    { "CSMSG_ADDUSER_PENDING", "I have sent him/her a message letting them know, and if they auth or register soon, I will finish adding them automatically." },
     { "CSMSG_ADDUSER_PENDING_ALREADY", "He or she is already pending addition to %s once he/she auths with $b$N$b." },
     { "CSMSG_ADDUSER_PENDING_HEADER", "Users to add to channels pending logins:" }, /* Remove after testing? */
     { "CSMSG_ADDUSER_PENDING_LIST", "Channel %s user %s" },             /* Remove after testing? */
-    { "CSMSG_ADDUSER_PENDING_HEADER", "--------- End of pending list ----------" }, /* Remove after testing? */
+    { "CSMSG_ADDUSER_PENDING_FOOTER", "--------- End of pending list ----------" }, /* Remove after testing? */
     /*{ "CSMSG_ADDUSER_PENDING_NOTINCHAN", "That user is not in %s, and is not auth'd." }, */
-    { "CSMSG_ADDUSER_PENDING_TARGET", "Channel Services bot here, %s would like to add you to my userlist in channel %s, but you are not auth'd to $b$N$b. Please auth now, and you will be added. If you do not have an accont, type /msg $N help register" },
+    { "CSMSG_ADDUSER_PENDING_TARGET", "Channel Services bot here: %s would like to add you to my userlist in channel %s, but you are not authenticated to $b$N$b. Please authenticate now and you will be added. If you do not have an account, type /msg $N help register" },
     { "CSMSG_CANNOT_TRIM", "You must include a minimum inactivity duration of at least 60 seconds to trim." },
 
     { "CSMSG_NO_SELF_CLVL", "You cannot change your own access." },
@@ -1311,8 +1313,15 @@ process_adduser_pending(struct userNode *user)
     while((ap = find_adduser_pending(NULL, user)))
     {
         struct userData *actee;
-        actee = add_channel_user(ap->channel->channel_info, ap->user->handle_info, ap->level, 0, NULL);
-        scan_user_presence(actee, NULL);
+        if(GetTrueChannelAccess(ap->channel->channel_info, ap->user->handle_info))
+        {
+            /* Already on the userlist. do nothing*/
+        }
+        else
+        {
+            actee = add_channel_user(ap->channel->channel_info, ap->user->handle_info, ap->level, 0, NULL);
+            scan_user_presence(actee, NULL);
+        }
         del_adduser_pending(ap);
     }
 }
@@ -1880,6 +1889,8 @@ static CHANSERV_FUNC(cmd_register)
     char *chan_name;
     unsigned int new_channel, force=0;
     struct do_not_register *dnr;
+    unsigned int n;
+
 
     if(channel)
     {
@@ -1895,8 +1906,7 @@ static CHANSERV_FUNC(cmd_register)
             return 0;
         }
 
-        if(!IsHelping(user)
-           && (!(mn = GetUserMode(channel, user)) || !(mn->modes & MODE_CHANOP)))
+        if(!IsHelping(user) && (!(mn = GetUserMode(channel, user)) || !(mn->modes & MODE_CHANOP)))
         {
             reply("CSMSG_MUST_BE_OPPED", channel->name);
             return 0;
@@ -1941,11 +1951,36 @@ static CHANSERV_FUNC(cmd_register)
             return 0;
         force = (argc > (new_channel+2)) && !irccasecmp(argv[new_channel+2], "force");
         dnr = chanserv_is_dnr(chan_name, handle);
+
+        /* Check if they are over the limit.. */
+        if((chanserv_get_owned_count(handle) >= chanserv_conf.max_owned) && !force)
+        {
+            reply("CSMSG_OWN_TOO_MANY", handle->handle, chanserv_conf.max_owned);
+            return 0;
+        }
+
     }
     else
     {
-       handle = user->handle_info;
+        handle = user->handle_info;
         dnr = chanserv_is_dnr(chan_name, handle);
+        /* Check if they are over the limit.. */
+        if((chanserv_get_owned_count(handle) >= chanserv_conf.max_owned) && !force)
+        {
+            reply("CSMSG_YOU_OWN_TOO_MANY", chanserv_conf.max_owned);
+            return 0;
+        }
+        /* Check if another service is in the channel */
+        if(channel)
+            for(n = 0; n < channel->members.used; n++)
+            {
+                mn = channel->members.list[n];
+                if((mn && mn->user && (mn->user->modes & FLAGS_SERVICE)) || IsLocal(mn->user))
+                {
+                    reply("CSMSG_ANOTHER_SERVICE");
+                    return 0;
+                }
+            }
     }
     if(dnr && !force)
     {
@@ -1956,11 +1991,13 @@ static CHANSERV_FUNC(cmd_register)
         return 0;
     }
 
+    /* now handled above for message specilization *
     if((chanserv_get_owned_count(handle) >= chanserv_conf.max_owned) && !force)
     {
         reply("CSMSG_OWN_TOO_MANY", handle->handle, chanserv_conf.max_owned);
         return 0;
     }
+    */
 
     if(new_channel)
         channel = AddChannel(argv[1], now, NULL, NULL, NULL);
@@ -4469,32 +4506,34 @@ static CHANSERV_FUNC(cmd_resync)
         }
         else if(uData && uData->access >= UL_HALFOP /*cData->lvlOpts[lvlGiveHalfOps]*/)
         {
-            if(!(mn->modes & MODE_HALFOP))
+            if(mn->modes & MODE_CHANOP)
             {
-                changes->args[used].mode = MODE_HALFOP;
+                changes->args[used].mode = MODE_REMOVE |  MODE_CHANOP;
                 changes->args[used++].u.member = mn;
             }
-            if(mn->modes & MODE_CHANOP)
+            if(!(mn->modes & MODE_HALFOP))
             {
-                changes->args[used].mode = MODE_REMOVE | (mn->modes & ~MODE_CHANOP);
+                changes->args[used].mode = MODE_HALFOP;
                 changes->args[used++].u.member = mn;
             }
+            /* why cant halfops keep voice
             if(mn->modes & MODE_VOICE)
             {
                 changes->args[used].mode = MODE_REMOVE | (mn->modes & ~MODE_VOICE);
                 changes->args[used++].u.member = mn;
             }
+            */
         }
         else if(uData && uData->access >= UL_PEON /* cData->lvlOpts[lvlGiveVoice]*/)
         {
             if(mn->modes & MODE_CHANOP)
             {
-                changes->args[used].mode = MODE_REMOVE | (mn->modes & ~MODE_VOICE);
+                changes->args[used].mode = MODE_REMOVE | MODE_CHANOP;
                 changes->args[used++].u.member = mn;
             }
             if(mn->modes & MODE_HALFOP)
             {
-                changes->args[used].mode = MODE_REMOVE | (mn->modes & ~MODE_VOICE);
+                changes->args[used].mode = MODE_REMOVE | MODE_HALFOP;
                 changes->args[used++].u.member = mn;
             }
             if(!(mn->modes & MODE_VOICE))