Ver código fonte

Only raise limit when inviting a bot if needed (#44)

Bryan Drewery 14 anos atrás
pai
commit
02db2453a6
2 arquivos alterados com 10 adições e 13 exclusões
  1. 9 12
      src/mod/irc.mod/irc.c
  2. 1 1
      src/mod/irc.mod/irc.h

+ 9 - 12
src/mod/irc.mod/irc.c

@@ -808,14 +808,8 @@ getin_request(char *botnick, char *code, char *par)
     bool sendi = 0;
 
     if (chan->channel.maxmembers) {
-      int lim = (chan->channel.members - chan->channel.splitmembers) + 5, curlim = chan->channel.maxmembers;
-      if (curlim < lim) {
-        char s2[6] = "";
-
-        sendi = 1;
-        simple_snprintf(s2, sizeof(s2), "%d", lim);
-        add_mode(chan, '+', 'l', s2);
-        putlog(LOG_GETIN, "*", "inreq from %s/%s for %s - Raised limit to %d", botnick, nick, chan->dname, lim);
+      if (raise_limit(chan)) {
+        putlog(LOG_GETIN, "*", "inreq from %s/%s for %s - Raised limit", botnick, nick, chan->dname);
       }
     }
 
@@ -1395,15 +1389,15 @@ check_netfight(struct chanset_t *chan)
   chan->channel.fighting = 0;   /* we put this here because we need to clear it once per min */
 }
 
-void
+bool
 raise_limit(struct chanset_t *chan)
 {
   if (!chan || !me_op(chan))
-    return;
+    return false;
 
   /* Don't bother setting limit if the user has set a protect -l */
   if (chan->mode_mns_prot & CHANLIMIT)
-    return;
+    return false;
 
   int nl = (chan->channel.members - chan->channel.splitmembers) + chan->limitraise;	/* new limit */
   int i = chan->limitraise >> 2;			/* DIV 4 */
@@ -1412,15 +1406,18 @@ raise_limit(struct chanset_t *chan)
   int ll = nl - i;					/* lower limit */
 
   if ((chan->channel.maxmembers > ll) && (chan->channel.maxmembers < ul))
-    return;                     /* the current limit is in the range, so leave it. */
+    return false;                     /* the current limit is in the range, so leave it. */
 
   if (nl != chan->channel.maxmembers) {
     char s[6] = "";
 
     simple_snprintf(s, sizeof(s), "%d", nl);
     add_mode(chan, '+', 'l', s);
+
+    return true;
   }
 
+  return false;
 }
 
 void check_shouldjoin(struct chanset_t* chan)

+ 1 - 1
src/mod/irc.mod/irc.h

@@ -146,7 +146,7 @@ inline void check_this_mask(const char type, struct chanset_t *chan, char *mask,
 }
 
 void check_this_user(char *, int, char *);
-void raise_limit(struct chanset_t *);
+bool raise_limit(struct chanset_t *);
 void enforce_closed(struct chanset_t *);
 void recheck_channel(struct chanset_t *, int);
 void recheck_channel_modes(struct chanset_t *);