X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FIRC%2FIrcHelpers.pl;h=e0acbcf5584a12e94a66c02d20e36c416ec8b88b;hb=64b1ab9e23f7895f1ab62a8168d77955a11451fc;hp=b2b33d1779e043bd219cd446d062697c7316182e;hpb=a87ffc02b13e2cf37692928187ae3b97cd70dd79;p=infobot.git diff --git a/src/IRC/IrcHelpers.pl b/src/IRC/IrcHelpers.pl index b2b33d1..e0acbcf 100644 --- a/src/IRC/IrcHelpers.pl +++ b/src/IRC/IrcHelpers.pl @@ -13,12 +13,14 @@ if (&IsParam("useStrict")) { use strict; } ####################################################################### ##### -# Usage: &hookMode($chan, $modes, @targets); +# Usage: &hookMode($nick, $modes, @targets); sub hookMode { - my ($chan, $modes, @targets) = @_; + my ($nick, $modes, @targets) = @_; my $parity = 0; - $chan = lc $chan; # !!!. + if ($chan =~ tr/A-Z/a-z/) { + &VERB("hookMode: cased $chan.",2); + } my $mode; foreach $mode (split(//, $modes)) { @@ -43,6 +45,11 @@ sub hookMode { # modes w/ target affecting nick => cache it. if ($mode =~ /[bov]/) { + if ($mode eq "o" and $nick eq "ChanServ" and $target =~ /^\Q$ident\E$/i) { + &DEBUG("hookmode: chanserv deopped us! asking"); + &chanServCheck($chan); + } + $channels{$chan}{$mode}{$target}++ if $parity; delete $channels{$chan}{$mode}{$target} if !$parity; } @@ -85,7 +92,7 @@ sub hookMsg { # addressing revamped by the xk. ### below needs to be fixed... if (&IsParam("addressCharacter")) { - if ($message =~ s/^$param{'addressCharacter'}//) { + if ($message =~ s/^\Q$param{'addressCharacter'}\E//) { $addrchar = 1; $addressed = 1; } @@ -177,12 +184,12 @@ sub hookMsg { # flood overflow protection. if ($addressed) { - foreach (keys %{$flood{$floodwho}}) { + foreach (keys %{ $flood{$floodwho} }) { next unless (time() - $flood{$floodwho}{$_} > $interval); delete $flood{$floodwho}{$_}; } - my $i = scalar keys %{$flood{$floodwho}}; + my $i = scalar keys %{ $flood{$floodwho} }; if ($i > $count) { &msg($who,"overflow of messages ($i > $count)"); &status("FLOOD overflow detected from $floodwho; ignoring"); @@ -254,10 +261,19 @@ sub chanLimitVerify { my($chan) = @_; my $l = $channels{$chan}{'l'}; + &DEBUG("cLV: netsplitservers: ".scalar(keys %netsplitservers) ); + &DEBUG("cLV: netsplit: ".scalar(keys %netsplit) ); + + if (scalar keys %netsplit) { + &WARN("clV: netsplit active (1); skipping."); + return; + } + # only change it if it's not set. if (defined $l and &IsChanConf("chanlimitcheck")) { my $plus = &getChanConfDefault("chanlimitcheckPlus", 5, $chan); my $count = scalar(keys %{ $channels{$chan}{''} }); + my $int = &getChanConfDefault("chanlimitcheckInterval", 10, $chan); my $delta = $count + $plus - $l; $delta =~ s/^\-//; @@ -266,22 +282,50 @@ sub chanLimitVerify { &WARN("clc: stupid to have plus at $plus, fix it!"); } - if (exists $cache{ "chanlimitChange_$chan" }) { - if (time() - $cache{ "chanlimitChange_$chan" } < 60) { - &DEBUG("not going to change chanlimit!"); + if (exists $cache{chanlimitChange}{$chan}) { + if (time() - $cache{chanlimitChange}{$chan} < $int*60) { return; } - delete $cache{ "chanlimitChange_$chan" }; } - ### todo: check if we have ops. - ### todo: if not, check if nickserv/chanserv is avail. + &chanServCheck($chan); + ### todo: unify code with chanlimitcheck() if ($delta > 5) { - &status("clc: big change in limit; changing."); + &status("clc: big change in limit; going for it."); &rawout("MODE $chan +l ".($count+$plus) ); + $cache{chanlimitChange}{$chan} = time(); } } } +sub chanServCheck { + ($chan) = @_; + + if (!defined $chan or $chan =~ /^$/) { + &WARN("chanServCheck: chan == NULL."); + return 0; + } + + if ($chan =~ tr/A-Z/a-z/) { + &DEBUG("chanServCheck: lowercased chan ($chan)"); + } + + if (! &IsChanConf("chanServ_ops") ) { + return 0; + } + + &VERB("chanServCheck($chan) called.",2); + + if ( &IsParam("nickServ_pass") and !$nickserv) { + &DEBUG("chanServ_ops($chan): nickserv enabled but not alive? (ircCheck)"); + return 0; + } + return 0 if (exists $channels{$chan}{'o'}{$ident}); + + &status("ChanServ ==> Requesting ops for $chan. (chanServCheck)"); + &rawout("PRIVMSG ChanServ :OP $chan $ident"); + return 1; +} + 1;