Преглед на файлове

Merge branch 'ducch-171-closed-exempt'

* ducch-171-closed-exempt:
  * Consider ops when checking 'closed-exempt voice'
  * Move closed-exempt checking and compare against member's actual flags
  * Update docs
  * Added Closed-exempt flag op|voice|none. #171

Conflicts:
	doc/UPDATES
	src/chan.h
	src/mod/channels.mod/userchan.c
Bryan Drewery преди 14 години
родител
ревизия
422c606d8b
променени са 7 файла, в които са добавени 36 реда и са изтрити 2 реда
  1. 1 0
      doc/UPDATES
  2. 6 0
      doc/help.txt
  3. 1 0
      src/chan.h
  4. 21 0
      src/mod/channels.mod/chanmisc.c
  5. 1 0
      src/mod/channels.mod/cmdschan.c
  6. 2 1
      src/mod/channels.mod/userchan.c
  7. 4 1
      src/mod/irc.mod/chan.c

+ 1 - 0
doc/UPDATES

@@ -45,6 +45,7 @@
   * Remove unneeded chanset 'nomassjoin'
   * Add chanset 'capslimit' to handle % of message that can be in caps before kick (#8)
   * Add chanset 'colorlimit' to handle how many color codes are allowed in a message before kick (#8)
+  * Add chanset 'closed-exempt' which will allow exempting non-users (who are opped or voice) from being kicked. (fixes #171)
 
 1.3.4 - http://wraith.botpack.net/milestone/1.3.4
   * Fix various compile warnings with newer GCC

+ 6 - 0
doc/help.txt

@@ -408,6 +408,12 @@ See also: link%{+a}, newhub%{-}
                               None/0         Stick to regular checking (+x)
                               Op/1           Ops are exempt from flood checks
                               Voice/2        Voices are exempt from flood checks
+        $bclosed-exempt$b     Should clients be exempt from +closed kicks based
+                              on their channel status?
+                              Valid values are:
+                              None/0         Stick to regular user checking (+o)
+                              Op/1           Ops are exempt from +closed kicks
+                              Voice/2        Voices are exempt from +closed kicks
  
         $bflood-lock-time$b   How long in seconds to keep the channel locked
                          during drone floods.

+ 1 - 0
src/chan.h

@@ -196,6 +196,7 @@ struct chanset_t {
   int closed_ban;
   int closed_private;
   int closed_invite;
+  int closed_exempt_mode;
   deflag_t bad_cookie;
   deflag_t manop;
   deflag_t mdop;

+ 21 - 0
src/mod/channels.mod/chanmisc.c

@@ -564,6 +564,27 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item,
         }
       } else
         chan->flood_exempt_mode = atoi(item[i]);
+    } else if (!strcmp(item[i], "closed-exempt")) {
+      i++;
+      if (i >= items) {
+        if (result)
+          strlcpy(result, "channel closed-exempt needs argument", RESULT_LEN);
+        return ERROR;
+      }
+      if (!str_isdigit(item[i])) {
+        if (!strcasecmp("Op",  item[i]))
+          chan->closed_exempt_mode = CHAN_FLAG_OP;
+        else if (!strcasecmp("Voice", item[i]))
+          chan->closed_exempt_mode = CHAN_FLAG_VOICE;
+        else if (!strcasecmp("None", item[i]))
+          chan->closed_exempt_mode = 0;
+        else {
+          if (result)
+            strlcpy(result, "channel closed-exempt only accepts Op|Voice|None", RESULT_LEN);
+          return ERROR;
+        }
+      } else
+        chan->closed_exempt_mode = atoi(item[i]);
     } else if (!strcmp(item[i], "flood-lock-time")) {
       i++;
       if (i >= items) {

+ 1 - 0
src/mod/channels.mod/cmdschan.c

@@ -1239,6 +1239,7 @@ static void cmd_chaninfo(int idx, char *par)
     SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!");
     SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!");
     SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!");
+    SHOW_INT("Closed-Exempt:", chan->closed_exempt_mode, F_STR(chan->closed_exempt_mode), "None");
     SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever");
     SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR(chan->flood_exempt_mode), "None");
     SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't");

+ 2 - 1
src/mod/channels.mod/userchan.c

@@ -718,7 +718,7 @@ chanmode { %s } groups { %s } bad-cookie %d manop %d mdop %d mop %d limit %d rev
 flood-chan %d:%d flood-bytes %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d flood-mjoin %d:%d \
 flood-mpub %d:%d flood-mbytes %d:%d flood-mctcp %d:%d \
-capslimit %d colorlimit %d closed-ban %d closed-invite %d closed-private %d ban-time %d \
+capslimit %d colorlimit %d closed-ban %d closed-invite %d closed-private %d closed-exempt %d ban-time %d \
 exempt-time %d invite-time %d voice-non-ident %d auto-delay %d \
 flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
 %cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch %cfloodban \
@@ -758,6 +758,7 @@ flood-exempt %d flood-lock-time %d knock %d fish-key { %s } \
  */
         chan->closed_invite,
         chan->closed_private,
+        chan->closed_exempt_mode,
         chan->ban_time,
         chan->exempt_time,
         chan->invite_time,

+ 4 - 1
src/mod/irc.mod/chan.c

@@ -447,7 +447,10 @@ static void priority_do(struct chanset_t * chan, bool opsonly, int action, bool
                   flush_mode(chan, QUICK);
                 return;
               }
-            } else if ((action == PRIO_KICK) && !chan_sentkick(m)) {
+            } else if ((action == PRIO_KICK) && !chan_sentkick(m) &&
+                // Check closed-exempt
+                !((chan_hasop(m) && chan->closed_exempt_mode == CHAN_FLAG_OP) ||
+                  ((chan_hasvoice(m) || chan_hasop(m)) && chan->closed_exempt_mode == CHAN_FLAG_VOICE))) {
               ++actions;
               ++sent;
               if (chan->closed_ban)