Ver código fonte

* Added Closed-exempt flag op|voice|none. #171

Mark 14 anos atrás
pai
commit
f8a272ed2c

+ 1 - 0
src/chan.h

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

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

@@ -1283,6 +1283,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");

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

@@ -519,6 +519,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) {

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

@@ -720,7 +720,7 @@ bd::String channel_to_string(struct chanset_t* chan, bool force_inactive) {
 chanmode { %s } bad-cookie %d manop %d mdop %d mop %d limit %d ban-type %d \
 flood-chan %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 \
-closed-ban %d closed-invite %d closed-private %d ban-time %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 \
 %cmeankicks %cenforcebans %cdynamicbans %cuserbans %cbitch \
@@ -752,6 +752,7 @@ flood-exempt %d flood-lock-time %d knock %d \
  */
         chan->closed_invite,
         chan->closed_private,
+        chan->closed_exempt_mode,
         chan->ban_time,
         chan->exempt_time,
         chan->invite_time,

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

@@ -749,6 +749,10 @@ static void do_closed_kick(struct chanset_t *chan, memberlist *m)
 
   simple_snprintf(s, sizeof(s), "%s!%s", m->nick, m->userhost);
 
+  if ((m && chan->closed_exempt_mode == CHAN_FLAG_OP) ||
+       (m && chan->closed_exempt_mode == CHAN_FLAG_VOICE))
+    return;
+
   if (!(use_exempts &&
         (u_match_mask(global_exempts,s) ||
          u_match_mask(chan->exempts, s)))) {