]> git.donarmstrong.com Git - infobot.git/commitdiff
added flood protection for notice()
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 18 Apr 2001 14:50:09 +0000 (14:50 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 18 Apr 2001 14:50:09 +0000 (14:50 +0000)
added connectivity percentage to ircstats.
other changes forgotten

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@449 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/Irc.pl
src/IRC/Schedulers.pl
src/UserExtra.pl
src/core.pl

index b8ee86fdde44d3ebee218d21f2d88d14e80b76be..13dcb2280269dbf3fd28441868a60417c48bbb6a 100644 (file)
@@ -262,8 +262,8 @@ sub action {
     rawout($rawout);
 }
 
-# Usage: &action(nick || chan, txt);
-sub notice{
+# Usage: &notice(nick || chan, txt);
+sub notice {
     my ($target, $txt) = @_;
     if (!defined $txt) {
        &DEBUG("action: txt == NULL.");
@@ -272,6 +272,25 @@ sub notice{
 
     &status("-$target- $txt");
 
+    my $t      = time();
+
+    if ($t == $nottime) {
+       $notcount++;
+       $notsize += length $txt;
+
+       if ($notcount % 4 and $notcount) {
+           sleep 1;
+       } elsif ($notsize > 1500) {
+           sleep 1;
+           $notsize -= 1500;
+       }
+
+    } else {
+       $notcount       = 0;
+       $nottime        = $t;
+       $notsize        = length $msg;
+    }
+
     $conn->notice($target, $txt);
 }
 
index 59ca412860dd112fd2912d031ef0866954f1704b..1587d0b63d5c1d3826c75e4426c2d91747d0e920 100644 (file)
@@ -707,6 +707,7 @@ sub ircCheck {
     &DEBUG("ircstats...");
     &DEBUG("  pubsleep: $pubsleep");
     &DEBUG("  msgsleep: $msgsleep");
+    &DEBUG("  notsleep: $notsleep");
 
     ### USER FILE.
     if ($utime_userfile > $wtime_userfile and time() - $wtime_userfile > 3600) {
index 1a62202f5afccd530d38c3a853bab2a42d26356a..dae2d6bb2388a3c72b6dec7719c12ae8b96b2e25 100644 (file)
@@ -643,8 +643,6 @@ sub userCommands {
            $p =~ s/\.$//
        }
 
-       &DEBUG("connectivity => $p %");
-
        if ($total_time != (time() - $ircstats{'ConnectTime'}) ) {
            my $tt_format = &Time2String($total_time);
            &DEBUG("tt_format => $tt_format");
@@ -657,7 +655,8 @@ sub userCommands {
        } else {
            $reply = "Currently I'm hooked up to $ircstats{'Server'} but only".
                " for $format_time.  ".
-               "I had to reconnect \002$count\002 times.";
+               "I had to reconnect \002$count\002 times.".
+               "   Connectivity: $p %";
        }
 
        ### REASON.
index 48fe3cf1900502776ad4ebf5330a7523923d9ea1..4caf49330df9aa9d7903ec8bbe7b0f30df03fdbb 100644 (file)
@@ -21,6 +21,7 @@ use vars qw(
        $utime_chanfile $wtime_chanfile $ucount_chanfile
        $pubsize $pubcount $pubtime $pubsleep
        $msgsize $msgcount $msgtime $msgsleep
+       $notsize $notcount $nottime $notsleep
 );
 
 # dynamic hash.
@@ -62,6 +63,9 @@ $msgcount     = $msgsleep     = 0;
 $pubtime       = 0;
 $pubsize       = 0;
 $pubcount      = $pubsleep     = 0;
+$nottime       = 0;
+$notsize       = 0;
+$notcount      = $notsleep     = 0;
 ###
 $bot_version   = "blootbot cvs (20010214) -- $^O";
 $noreply       = "NOREPLY";