From 4e06c875ee1ada22edc8eecdaeea976f15506d76 Mon Sep 17 00:00:00 2001 From: dms Date: Wed, 3 Jan 2001 13:31:25 +0000 Subject: [PATCH] - floodjoinCheck. - note on endofmotd. - Moved ircstats from Irc.pl to on_endofmotd#IrcHooks.pl git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@214 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/IRC/Irc.pl | 69 ++++++++++++++++++++++++++++++++++----------- src/IRC/IrcHooks.pl | 6 ++++ 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index 8232a22..a11f072 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -22,8 +22,9 @@ sub ircloop { while (1) { # JUST IN CASE. irq was complaining about this. if ($lastrun == time()) { + &DEBUG("hrm... lastrun == time()"); $error++; - sleep 1; + sleep 10; next; } @@ -33,7 +34,6 @@ sub ircloop { $lastrun = time(); next; } - &DEBUG("ircloop: _ => '$_'."); next unless (exists $ircPort{$_}); my $retval = &irc($_, $ircPort{$_}); @@ -61,7 +61,6 @@ sub irc { select STDOUT; &status("Connecting to port $port of server $server ..."); - sleep 3; # lame hack. # host->ip. if ($server =~ /\D$/) { @@ -91,17 +90,12 @@ sub irc { return 1; } + &clearIRCVars(); + # change internal timeout value for scheduler. $irc->{_timeout} = 10; # how about 60? - # clear out hashes before connecting... - &clearIRCVars(); - - $ident = $param{'ircNick'}; - ### IRCSTATS. - $ircstats{'ConnectTime'} = time(); - $ircstats{'ConnectCount'}++; - $ircstats{'Server'} = "$server:$port"; + $ircstats{'Server'} = "$server:$port"; # handler stuff. $conn->add_handler('caction', \&on_action); @@ -134,7 +128,7 @@ sub irc { $conn->add_global_handler(352, \&on_who); $conn->add_global_handler(353, \&on_names); $conn->add_global_handler(366, \&on_endofnames); - $conn->add_global_handler(376, \&on_endofmotd); + $conn->add_global_handler(376, \&on_endofmotd); # on_connect. $conn->add_global_handler(433, \&on_nick_taken); $conn->add_global_handler(439, \&on_targettoofast); # end of handler stuff. @@ -202,10 +196,6 @@ sub msg { } $last{msg} = $msg; - if ($msg =~ /\cB/) { - &status("^B hrm."); - } - &status(">$nick< $msg"); $conn->privmsg($nick, $msg) if (&whatInterface() =~ /IRC/); } @@ -633,4 +623,51 @@ sub closeDCC { } } +sub joinfloodCheck { + my($who,$chan,$userhost) = @_; + + return unless (&IsParam("joinfloodCheck")); + + if (exists $netsplit{lc $who}) { # netsplit join. + &DEBUG("jfC: $who was in netsnipe; not checking."); + } + + if (exists $floodjoin{$chan}{$who}{Time}) { + &WARN("floodjoin{$chan}{$who} already exists?"); + } + + $floodjoin{$chan}{$who}{Time} = time(); + $floodjoin{$chan}{$who}{Host} = $userhost; + + ### Check... + foreach (keys %floodjoin) { + my $c = $_; + my $count = scalar keys %{ $floodjoin{$c} }; + next unless ($count > 5); + &DEBUG("count => $count"); + + my $time; + foreach (keys %{ $floodjoin{$c} }) { + $time += $floodjoin{$c}{$_}{Time}; + } + &DEBUG("time => $time"); + $time /= $count; + + &DEBUG("new time => $time"); + } + + ### Clean it up. + my $delete = 0; + foreach $chan (keys %floodjoin) { + foreach $who (keys %{ $floodjoin{$chan} }) { + my $time = time() - $floodjoin{$chan}{$who}{Time}; + next unless ($time > 10); + delete $floodjoin{$chan}{$who}; + $delete++; + } + } + + &DEBUG("jfC: $delete deleted.") if ($delete); +} + 1; diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 8351d9e..8be2723 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -115,6 +115,12 @@ sub on_chat { sub on_endofmotd { my ($self) = @_; + # what's the following for? + $ident = $param{'ircNick'}; + # update IRCStats. + $ircstats{'ConnectTime'} = time(); + $ircstats{'ConnectCount'}++; + if (&IsParam("wingate")) { my $file = "$bot_base_dir/$param{'ircUser'}.wingate"; open(IN, $file); -- 2.39.2