#######################################################################
#####
-# 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)) {
# 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;
}
# 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;
}
# 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");
my($chan) = @_;
my $l = $channels{$chan}{'l'};
+ if (scalar keys %netsplitservers) {
+ &WARN("clV: netsplit active (1); skipping. (netsplit => $netsplit)");
+ 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/^\-//;
&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.");
&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;
+ }
+
+ &DEBUG("chanServCheck($chan) called.");
+
+ 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;