From 9470a98f023bb0efa5569b87e825c281014bae14 Mon Sep 17 00:00:00 2001 From: dms Date: Wed, 18 Apr 2001 14:50:09 +0000 Subject: [PATCH] added flood protection for notice() 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 | 23 +++++++++++++++++++++-- src/IRC/Schedulers.pl | 1 + src/UserExtra.pl | 5 ++--- src/core.pl | 4 ++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index b8ee86f..13dcb22 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -262,8 +262,8 @@ sub action { rawout($rawout); } -# Usage: &action(nick || chan, txt); -sub notice{ +# Usage: ¬ice(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); } diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 59ca412..1587d0b 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -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) { diff --git a/src/UserExtra.pl b/src/UserExtra.pl index 1a62202..dae2d6b 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -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. diff --git a/src/core.pl b/src/core.pl index 48fe3cf..4caf493 100644 --- a/src/core.pl +++ b/src/core.pl @@ -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"; -- 2.39.5