From 1ca536caa602233a6f3a0cccf33b7cc57fc5f441 Mon Sep 17 00:00:00 2001 From: djmcgrath Date: Fri, 2 Nov 2007 05:27:02 +0000 Subject: [PATCH] * Replaced chanServ_ops in infobot.config with chansetable +chanServCheck * Fixed chanServCheck to reop on deop in channel with +chanServCheck git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1614 c11ca15a-4712-0410-83d8-924469b57eb5 --- files/sample/infobot.chan | 1 + files/sample/infobot.config | 3 +- src/IRC/IrcHelpers.pl | 115 +++++++++++++++++------------------- 3 files changed, 55 insertions(+), 64 deletions(-) diff --git a/files/sample/infobot.chan b/files/sample/infobot.chan index 3d52876..330a80a 100644 --- a/files/sample/infobot.chan +++ b/files/sample/infobot.chan @@ -24,6 +24,7 @@ _default +News +BZFlag + +chanServCheck +Debian +DebianExtra +Dict diff --git a/files/sample/infobot.config b/files/sample/infobot.config index 2e855b2..073a81e 100644 --- a/files/sample/infobot.config +++ b/files/sample/infobot.config @@ -18,9 +18,8 @@ set ircHost 0.0.0.0 set owner OWNER -# nickserv/chanserv support. +# nickserv support. ###set nickServ_pass PASSWORD -###set chanServ_ops #chan1 #chan2 # default quit message. set quitMsg adios amigos diff --git a/src/IRC/IrcHelpers.pl b/src/IRC/IrcHelpers.pl index 53f5e07..f3cb96f 100644 --- a/src/IRC/IrcHelpers.pl +++ b/src/IRC/IrcHelpers.pl @@ -13,61 +13,58 @@ ##### # Usage: &hookMode($nick, $modes, @targets); sub hookMode { - my ($nick, $modes, @targets) = @_; - my $parity = 0; - - if ($chan =~ tr/A-Z/a-z/) { - &VERB("hookMode: cased $chan.",2); - } + my ( $nick, $modes, @targets ) = @_; + my $parity = 0; my $mode; - foreach $mode (split(//, $modes)) { - # sign. - if ($mode =~ /[-+]/) { - $parity = 1 if ($mode eq "+"); - $parity = 0 if ($mode eq "-"); - next; - } - - # mode with target. - if ($mode =~ /[bklov]/) { - my $target = shift @targets; - - if ($parity) { - $chanstats{$chan}{'Op'}++ if ($mode eq 'o'); - $chanstats{$chan}{'Ban'}++ if ($mode eq 'b'); - } else { - $chanstats{$chan}{'Deop'}++ if ($mode eq 'o'); - $chanstats{$chan}{'Unban'}++ if ($mode eq 'b'); - } - - # modes w/ target affecting nick => cache it. - if ($mode =~ /[bov]/) { - $channels{$chan}{$mode}{$target}++ if $parity; - delete $channels{$chan}{$mode}{$target} if !$parity; - - # lets do some custom stuff. - if ($mode eq 'o' and $parity) { - if ($nick eq 'ChanServ' and $target =~ /^\Q$ident\E$/i) { - &VERB("hookmode: chanserv deopped us! asking",2); - &chanServCheck($chan); - } - - &chanLimitVerify($chan); - } - } - - if ($mode =~ /[l]/) { - $channels{$chan}{$mode} = $target if $parity; - delete $channels{$chan}{$mode} if !$parity; - } - } - - # important channel modes, targetless. - if ($mode =~ /[mt]/) { - $channels{$chan}{$mode}++ if $parity; - delete $channels{$chan}{$mode} if !$parity; - } + foreach $mode ( split( //, $modes ) ) { + + # sign. tmp parity needed to store current state + if ( $mode =~ /[-+]/ ) { + $parity = 1 if ( $mode eq "+" ); + $parity = 0 if ( $mode eq "-" ); + next; + } + + # mode with target. + if ( $mode =~ /[bklov]/ ) { + my $target = shift @targets; + + if ($parity) { + $chanstats{ lc $chan }{'Op'}++ if ( $mode eq 'o' ); + $chanstats{ lc $chan }{'Ban'}++ if ( $mode eq 'b' ); + } else { + $chanstats{ lc $chan }{'Deop'}++ if ( $mode eq 'o' ); + $chanstats{ lc $chan }{'Unban'}++ if ( $mode eq 'b' ); + } + + # modes w/ target affecting nick => cache it. + if ( $mode =~ /[bov]/ ) { + $channels{ lc $chan }{$mode}{$target}++ if $parity; + delete $channels{ lc $chan }{$mode}{$target} if !$parity; + + # lets do some custom stuff. + if ( $mode =~ /o/ and not $parity ) { + if ( $target =~ /^\Q$ident\E$/i ) { + &VERB( "hookmode: someone deopped us!", 2 ); + &chanServCheck($chan); + } + + &chanLimitVerify($chan); + } + } + + if ( $mode =~ /[l]/ ) { + $channels{ lc $chan }{$mode} = $target if $parity; + delete $channels{ lc $chan }{$mode} if !$parity; + } + } + + # important channel modes, targetless. + if ( $mode =~ /[mt]/ ) { + $channels{ lc $chan }{$mode}++ if $parity; + delete $channels{ lc $chan }{$mode} if !$parity; + } } } @@ -356,13 +353,7 @@ sub chanServCheck { return 0; } - if ($chan =~ tr/A-Z/a-z/) { - &DEBUG("chanServCheck: lowercased chan ($chan)"); - } - - if (! &IsChanConf('chanServ_ops') > 0) { - return 0; - } + return unless (&IsChanConf('chanServCheck')); &VERB("chanServCheck($chan) called.",2); @@ -373,12 +364,12 @@ sub chanServCheck { # check for first hash then for next hash. # TODO: a function for &ischanop()? &isvoice()? - if (exists $channels{$chan} and exists $channels{$chan}{'o'}{$ident}) { + if (exists $channels{lc $chan} and exists $channels{lc $chan}{'o'}{$ident}) { return 0; } &status("ChanServ ==> Requesting ops for $chan. (chanServCheck)"); - &rawout("PRIVMSG ChanServ :OP $chan $ident"); + &msg('ChanServ', "OP $chan"); return 1; } -- 2.39.2