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

* When in +f, automatically remove -D

Bryan Drewery преди 16 години
родител
ревизия
ccedef4c46
променени са 6 файла, в които са добавени 34 реда и са изтрити 14 реда
  1. 4 0
      doc/UPDATES
  2. 3 4
      src/flags.c
  3. 20 8
      src/mod/server.mod/server.c
  4. 1 1
      src/mod/server.mod/server.h
  5. 4 1
      src/mod/server.mod/servmsg.c
  6. 2 0
      src/set.c

+ 4 - 0
doc/UPDATES

@@ -1,3 +1,7 @@
+* Floodbots (+f) are now listed in cmd_userlist
+* Floodbots (+f) will automatically unDEAF themselves to they can monitor the channel for floods (namely flood-chan).
+  Note that this is done about 10 seconds after adding +f to a bot. Removing +f will set DEAF again.
+
 1.3 - http://wraith.botpack.net/milestone/1.3
 * Binary / shell / startup changes
   * Binary error messages are no longer obscure numbers or fake segfaults. (Compile with OBSCURE_ERRORS to re-enable)

+ 3 - 4
src/flags.c

@@ -513,12 +513,11 @@ dovoice(struct chanset_t *chan)
 int
 doflood(struct chanset_t *chan)
 {
-  if (!chan)
-    return 0;
-
   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_BOT, 0, 0, 0 };
+  if (!chan)
+    fr.match |= FR_ANYWH;
 
-  get_user_flagrec(conf.bot->u, &fr, chan->dname);
+  get_user_flagrec(conf.bot->u, &fr, chan ? chan->dname : NULL);
   if (glob_doflood(fr) || chan_doflood(fr))
     return 1;
   return 0;

+ 20 - 8
src/mod/server.mod/server.c

@@ -98,6 +98,7 @@ static bool use_penalties = 0;
 static int use_fastdeq;
 size_t nick_len = 9;			/* Maximal nick length allowed on the network. */
 char deaf_char = 0;
+bool deaf_set = 0;
 char callerid_char = 0;
 
 static bool double_mode = 0;		/* allow a msgs to be twice in a queue? */
@@ -1003,15 +1004,26 @@ static void server_secondly()
         ++ison_cnt;
     }
 
-    if (ison_time == 0) //If someone sets this to 0, all hell will break loose!
-      ison_time = 10;
-    if (ison_cnt >= ison_time) {
-      server_send_ison();
-      ison_cnt = 0;
-    } else
-      ++ison_cnt;
-  }
+    if (!loading) {
+      static int cnt_10 = 0;
+
+      // Every 10 seconds
+      if (cnt_10 == 9) {
+        // Ensure that +D/+f are not conflicting
+
+        // In +D but am +f, need to -D
+        if (deaf_set && doflood(NULL)) {
+          dprintf(DP_SERVER, "MODE %s -%c\n", botname, deaf_char);
+        } else if (!deaf_set && use_deaf && deaf_char) {
+          // Not +D but should be, probably had +f removed.
+          dprintf(DP_SERVER, "MODE %s +%c\n", botname, deaf_char);
+        }
 
+        cnt_10 = 0;
+      } else
+        ++cnt_10;
+    }
+  }
 }
 
 static void server_check_lag()

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

@@ -46,7 +46,7 @@ enum {
 
 extern bind_table_t	*BT_ctcp, *BT_ctcr, *BT_msgc;
 extern size_t		nick_len;
-extern bool		trigger_on_ignore, floodless, keepnick;
+extern bool		trigger_on_ignore, floodless, keepnick, deaf_set;
 extern int 		servidx, ctcp_mode, answer_ctcp, serv, curserv, default_alines;
 extern unsigned int     rolls;
 extern port_t		default_port, newserverport, curservport;

+ 4 - 1
src/mod/server.mod/servmsg.c

@@ -314,8 +314,10 @@ got005(char *from, char *msg)
       use_354 = 1;
     else if (!strcasecmp(tmp, "DEAF")) {
       deaf_char = p ? p[0] : 'D';
-      if (use_deaf)
+      if (use_deaf) {
         dprintf(DP_SERVER, "MODE %s +%c\n", botname, deaf_char);
+        deaf_set = 1;
+      }
     } else if (!strcasecmp(tmp, "CALLERID")) {
       callerid_char = p ? p[0] : 'g';
       if (use_callerid)
@@ -1179,6 +1181,7 @@ static void disconnect_server(int idx, int dolost)
   use_penalties = 0;
   use_354 = 0;
   deaf_char = 0;
+  deaf_set = 0;
   callerid_char = 0;
   in_callerid = 0;
   use_exempts = 0;

+ 2 - 0
src/set.c

@@ -285,6 +285,8 @@ sdprintf("var (mem): %s -> %s", var->name, datain ? datain : "(NULL)");
           which = '-';
         if (which) {
           char mode_char = strcmp(var->name, "deaf") == 0 ? deaf_char : callerid_char;
+          if (mode_char == deaf_char)
+            deaf_set = num;
           dprintf(DP_SERVER, "MODE %s %c%c\n", botname, which, mode_char);
         }
       }