Jelajahi Sumber

* Ported [2503] to 1.2.9 (fixes #69)

svn: 2612
Bryan Drewery 20 tahun lalu
induk
melakukan
64b96ffa74
2 mengubah file dengan 60 tambahan dan 24 penghapusan
  1. 1 0
      doc/UPDATES
  2. 59 24
      src/mod/channels.mod/tclchan.c

+ 1 - 0
doc/UPDATES

@@ -39,6 +39,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed a small error in help file for 'whom'.
 * Removed some legacy code from failed relays that attempts to connect to port+1, port+2, port+3... (might fix #177)
 * Fixed an invalid killsock error in sharing.
+* Fixed chanset 'flood-*' not working correctly. (#69)
 
 1.2.8
 * Fixed [bot]* cmds depending on case of botnicks.

+ 59 - 24
src/mod/channels.mod/tclchan.c

@@ -612,27 +612,59 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
       int *pthr = NULL;
       time_t *ptime = NULL;
       char *p = NULL;
-      bool all = 0;
 
-      if (!strcmp(item[i] + 6, "*"))
-        all = 1;
+      if (!strcmp(item[i] + 6, "*")) {
+        i++;
+        if (i >= items) {
+          if (result)
+            simple_snprintf(result, RESULT_LEN, "%s needs argument", item[i - 1]);
+          return ERROR;
+        }
+        p = strchr(item[i], ':');
+
+        int thr = 0;
+        time_t time = 0;
+
+        if (p) {
+          *p++ = 0;
 
-      if (all || !strcmp(item[i] + 6, "chan")) {
+          thr = atoi(item[i]);
+          time = atoi(p);
+
+          *--p = ':';
+        } else {
+          thr = atoi(item[i]);
+          time = 1;
+        }
+
+        chan->flood_pub_thr = thr;
+        chan->flood_pub_time = time;
+        chan->flood_join_thr = thr;
+        chan->flood_join_time = time;
+        chan->flood_ctcp_thr = thr;
+        chan->flood_ctcp_time = time;
+        chan->flood_kick_thr = thr;
+        chan->flood_kick_time = time;
+        chan->flood_deop_thr = thr;
+        chan->flood_deop_time = time;
+        chan->flood_nick_thr = thr;
+        chan->flood_nick_time = time;
+      } else if (!strcmp(item[i] + 6, "chan")) {
 	pthr = &chan->flood_pub_thr;
 	ptime = &chan->flood_pub_time;
-      } else if (all || !strcmp(item[i] + 6, "join")) {
+      } else if (!strcmp(item[i] + 6, "join")) {
 	pthr = &chan->flood_join_thr;
 	ptime = &chan->flood_join_time;
-      } else if (all || !strcmp(item[i] + 6, "ctcp")) {
+      } else if (!strcmp(item[i] + 6, "ctcp")) {
 	pthr = &chan->flood_ctcp_thr;
 	ptime = &chan->flood_ctcp_time;
-      } else if (all || !strcmp(item[i] + 6, "kick")) {
+      } else if (!strcmp(item[i] + 6, "kick")) {
 	pthr = &chan->flood_kick_thr;
 	ptime = &chan->flood_kick_time;
-      } else if (all || !strcmp(item[i] + 6, "deop")) {
+      } else if (!strcmp(item[i] + 6, "deop")) {
 	pthr = &chan->flood_deop_thr;
 	ptime = &chan->flood_deop_time;
-      } else if (all || !strcmp(item[i] + 6, "nick")) {
+      } else if (!strcmp(item[i] + 6, "nick")) {
 	pthr = &chan->flood_nick_thr;
 	ptime = &chan->flood_nick_time;
       } else {
@@ -640,21 +672,24 @@ int channel_modify(char *result, struct chanset_t *chan, int items, char **item)
 	  simple_snprintf(result, RESULT_LEN, "illegal channel flood type: %s", item[i]);
 	return ERROR;
       }
-      i++;
-      if (i >= items) {
-	if (result)
-	  simple_snprintf(result, RESULT_LEN, "%s needs argument", item[i - 1]);
-	return ERROR;
-      }
-      p = strchr(item[i], ':');
-      if (p) {
-	*p++ = 0;
-	*pthr = atoi(item[i]);
-	*ptime = atoi(p);
-	*--p = ':';
-      } else {
-	*pthr = atoi(item[i]);
-	*ptime = 1;
+
+      if (pthr && ptime) { //Ignore flood-*
+        i++;
+        if (i >= items) {
+          if (result)
+            simple_snprintf(result, RESULT_LEN, "%s needs argument", item[i - 1]);
+          return ERROR;
+        }
+        p = strchr(item[i], ':');
+        if (p) {
+          *p++ = 0;
+          *pthr = atoi(item[i]);
+          *ptime = atoi(p);
+          *--p = ':';
+        } else {
+          *pthr = atoi(item[i]);
+          *ptime = 1;
+        }
       }
     } else {
       if (result && item[i][0]) /* ignore "" */