namespace eval CyProt { ## ## This script protects AllOP Channels in Quakenet with L or Q Bot, not both ## You must give hime master that it is allowed to cleanchan or unbanall ## /msg L|Q chanlev #yourchan yourbot +mo ## ## It is require that you load a script that auth your Bot, like that from ## Cmouse @ http://help.quakenet.org/index.php?page=tcl_qscript/index ## ## When u dont have one, use the Simple one, where u replace USERNAME and PASSWORD with your data: # # # bind evnt - init-server CyProt::qauth; # proc qauth { type } { puthelp "PRIVMSG Q@CServe.quakenet.org :auth USERNAME PASSWORD" } # ## ## For optimize running, use only good script, that not use putquick for msgs ## Then the bot will lag or run to excess flood .. ## ## This script is yet not 100% multiple channel compatibel, use only on multichannel, when ## all channels have the same settings or you can shutup this function # # first edit: 26.Mar.2003 # last edit: 01.Jul.2003 ## setup vars set Channels [list #news.de ] set Badnicks [list]; # protect settings 0=Off/1=On/2=Set setudef flag BanOnKick setudef flag KickOnBan setudef flag KickOnMode setudef flag KickOnKick setudef flag KickOnDeop set KickOnBan 1; # default 1 (kick for banning someone without permission) set KickOnMode 0; # default 1 (kick for modechange without permission) set KickOnKick 1; # default 1 (kick for kicking someone without permission) set KickOnDeop 1; # default 1 (kick for deop someone without permission) setudef int ProtectLimit setudef int ProtectInvite setudef int ProtectColor setudef int ProtectCTCP setudef int ProtectSecret setudef int ProtectKey set ProtectLimit 1; # default 1 (remove limit) / 2 (reset to ProtectSetLimit) / 0 Off set ProtectInvite 1; # default 1 (remove InviteOnly) / 2 (use InviteOnly) / 0 Off set ProtectColor 2; # default 2 (use color protection) / 1 (no color protection) / 0 Off set ProtectCTCP 2; # default 2 (use ctcp protection) / 1 (no ctcp protection) / 0 Off set ProtectSecret 2; # default 1 (use prot) / 0 (off) / 2 (force secret) / 3 (force privat) set ProtectKey 1; # default 1 (no key) / 2 Use key / 0 Off set ProtectSetLimit 666; set ProtectSetKey [list] # "#channel1 key1 #channel2 key2 #channel3 key3" # normal u can let them default set Protect "m"; # default Global Masters set ProtectChan "o"; # default Chan Op set ProtectFriend "f"; # default Friends set ProtectChanFriend "f"; # default Friends set ProtectBot "b"; # default Bots set OverwriteGlobal "m"; # default Owner set OverwriteChannel "o"; # default Master set ServiceBot "L"; # only testet with L and Q on QuakeNet ## procs set Brain [list] if {![info exist Brain]} {set Brain [list]} if {![info exist Ver]} {set Ver "0.5.4"} if {![info exist Cmds]} {set Cmds [list]} set Channels [string tolower $Channels]; #help procs # sometimes pushmode dont work, i dont know why, but with puthelp it work, a little later :) proc mypushmode {where what {victim ""} {comment ""}} { pushmode $where $what $victim puthelp "MODE $where $what $victim" #putcmdlog "pushmode where $where what $what victim $victim comment $comment" } # return "" when nothing found, return "*" when more then once found other it return the handle proc mask2hand {mask} { set found 0; set msg ""; set mask [string tolower $mask] if [string match $mask [string tolower $::botname]] { incr found; lappend msg $::botnick } foreach user [userlist] { set nick [string tolower [hand2nick $user]] #putcmdlog "[string match $mask $nick![string tolower [getchanhost $nick]]] string match $mask $nick![string tolower [getchanhost $nick]]" if [string match $mask $nick![string tolower [getchanhost $nick]]] { #putcmdlog "Found $user" if !$found { incr found; set msg $user } { return "*" } } } return $msg; } proc mask2handlist {mask} { set msg ""; if [string match $mask [string tolower $::botname]] { lappend msg $::botnick } foreach user [userlist] { foreach host [getuser $user hosts] { set nick [string tolower [hand2nick $user]] if [string match $mask $nick![string tolower [getchanhost $nick]]] { lappend msg $user; break; } } } return $msg; } proc AddBadUser {nick} { putlog "Add BADUSER $nick" if {![validuser overtaker]} { adduser overtaker; chattr overtaker +d } setuser overtaker hosts [maskhost [getchanhost $nick]] setuser overtaker hosts [maskhost [string map {~ *} [getchanhost $nick]]] } proc CheckUser {hand chan} { set isprotected 0; set canoverwrite 0; if {[matchattr $hand $CyProt::Protect] || [matchattr $hand |$CyProt::ProtectChan $chan] || [matchattr $hand $CyProt::ProtectFriend] || [matchattr $hand |$CyProt::ProtectChanFriend $chan] || [matchattr $hand $CyProt::ProtectBot]} { set isprotected 1 } if {[matchattr $hand $CyProt::OverwriteGlobal] || [matchattr $hand |$CyProt::OverwriteChannel $chan] || [matchattr $hand $CyProt::ProtectBot]} { set canoverwrite 1 } return [list $isprotected $canoverwrite] } #pub procs proc pub_badlist { nick host hand chan text } { global botnick botname; set chan [string tolower $chan]; #if {[lsearch $CyProt::Channels $chan]==-1} {return} if {$botnick=="NewS-FlasH" && $chan=="#news.de"} { putmsg $chan [getuser overtaker hosts] } { putnotc $nick [getuser overtaker hosts] } } proc pub_badremove { nick host hand chan text } { global botnick botname; set chan [string tolower $chan]; #if {[lsearch $CyProt::Channels $chan]==-1} {return} set result [delhost overtaker $text] if {$botnick=="NewS-FlasH" && $chan=="#news.de"} { if {$result} { putmsg $chan "Removed $text. " } { putmsg $chan "ERROR: Can't removed $text. [getuser overtaker hosts] " } } { if {$result} { putnotc $nick "Removed $text. " } { putnotc $nick "ERROR: Can't removed $text. [getuser overtaker hosts] " } } } proc pub_badclear { nick host hand chan text } { set chan [string tolower $chan] setuser overtaker hosts putnotc $nick "Overtaker is now clear [getuser overtaker hosts]" } proc msg_badlist { nick host hand text } { foreach chan $CyProt::Channels { pub_badlist $nick $host $hand $chan $text } } proc msg_badremove { nick host hand text } { foreach chan $CyProt::Channels { pub_badremove $nick $host $hand $chan $text } } proc Mode {nick uhost hand chan mc {victim ""}} { #putcmdlog "mode $nick!$uhost ($hand) ch $chan mc $mc vic $victim" global botnick botname; if {$victim==""} {set victim [join [lrange $mc 1 end]]; set mc [join [lindex $mc 0]]} #putcmdlog "mode $nick!$uhost ($hand) ch $chan mc $mc vic $victim" set Chan $chan; set chan [string tolower $chan]; if {[lsearch $CyProt::Channels $chan]==-1} {return} if {$nick==$botnick} {return} set time [clock seconds] switch -exact -- $mc { {+o} { if {$victim==$botnick} { Time } if {[matchattr [nick2hand $victim] +d] || [matchattr [nick2hand $victim] |+d $chan]} { mypushmode $chan -o $victim {dont op $victim}; set nickcheck [CheckUser $hand $chan] puthelp "NOTICE $nick :Dont OP $victim, it has a reason that he dont has OP" } } {-o} { if {$victim==$botnick} { putlog "$nick deop't me in $chan" putquick "PRIVMSG $CyProt::ServiceBot :op $chan"; CyProt::AddBadUser $nick; if {[lsearch $CyProt::Badnicks "$nick-deop"]==-1} {lappend CyProt::Badnicks "$nick-deop"} if $CyProt::KickOnDeop { lappend CyProt::Brain kick $nick $chan $time } { putnotc $nick "WTF? Don't deop me!" } return 0 } elseif {$nick==$victim} { putcmdlog "$nick deop't himself" } { # else if {$victim==$botnick} set gethand [nick2hand $victim] set nickcheck [CheckUser $hand $chan] set destcheck [CheckUser $gethand $chan] putlog "$nick ($hand) \[$nickcheck\] deop't $victim ($gethand) \[$destcheck\] in $chan" if [lindex $nickcheck 1] { if [lindex $destcheck 0] { pushmode $chan +o $victim; putnotc $nick "Don't deop $victim, he is protected" } { putlog "but $nick can overwrite" } } { # else if [lindex $nickcheck 1] CyProt::AddBadUser $nick; if $CyProt::KickOnDeop { putquick "KICK $chan $nick :WTF?! Don't deop here anyone!" } { putnotc $nick "WTF? Don't deop here anyone!" } mypushmode $Chan +o $victim {dont deop}; } unset gethand; } } {+b} { set nickcheck [CheckUser $hand $chan] if [string match $victim $botname] { putlog "$nick ban me in $chan" CyProt::AddBadUser $nick; if [botisop $chan] { #putkick $chan $nick "WTF, play somewhere other" if ![lindex $nickcheck 1] { if $CyProt::KickOnBan { putquick "KICK $chan $nick :WTF? Don't ban me!" } { putnotc $nick "WTF? Don't ban me!" } } { putlog "but $nick can overwrite" } mypushmode $chan -b $victim {is me, remove ban} lappend CyProt::Brain unban $victim $chan $time if {[lsearch $CyProt::Badnicks "$nick-Ban"]==-1} {lappend CyProt::Badnicks $nick-Ban"} } { # is not op putquick "PRIVMSG $CyProt::ServiceBot :op $chan"; if {[lsearch $CyProt::Badnicks "$nick-Ban"]==-1} {lappend CyProt::Badnicks "$nick-Ban"} if ![lindex $nickcheck 1] { if $CyProt::KickOnBan { lappend CyProt::Brain kick $nick $chan $time } } { putlog "but $nick can overwrite" } lappend CyProt::Brain unban $victim $chan $time } } { # is not me set gethand [mask2hand $victim] set destcheck [CheckUser $gethand $chan] putlog "$nick ($hand) \[$nickcheck\] banned $victim ($gethand) \[$destcheck\] in $chan" if [lindex $nickcheck 1] { if [lindex $destcheck 0] { putserv "MODE $chan -b $victim"; putlog "$gethand is protected, remove ban $victim " } { putlog "but $nick can overwrite" } } { # else if [lindex $nickcheck 1] CyProt::AddBadUser $nick; if $CyProt::KickOnBan { putquick "KICK $chan $nick :WTF?! Dont ban here anyone!" } { putnotc $nick "WTF?! Dont ban here anyone!" } #putmsg $chan "mypushmode $Chan -b $victim" mypushmode $Chan -b $victim {is not me, remove ban}; #putserv "MODE $chan -b $victim" } } } {-l} { if {$CyProt::ProtectLimit!=0} { set nickcheck [CheckUser $hand $chan] #putlog "![lindex $nickcheck 0] && ![lindex $nickcheck 1] && $CyProt::KickOnMode" if {![lindex $nickcheck 1]} { if {$CyProt::ProtectLimit==1} { mypushmode $chan -l $victim; putcmdlog "Restore mode -l $victim" } { mypushmode $chan +l $CyProt::ProtectSetLimit; putcmdlog "Restore mode +l $CyProt::ProtectSetLimit" } } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-limit"]==-1} { lappend CyProt::Badnicks "$nick-limit" } } } {+l} { if {$CyProt::ProtectLimit!=0} { set nickcheck [CheckUser $hand $chan] #putlog "![lindex $nickcheck 0] && ![lindex $nickcheck 1] && $CyProt::KickOnMode" if {![lindex $nickcheck 1]} { if {$CyProt::ProtectLimit==1} { mypushmode $chan -l $victim; putcmdlog "Restore mode -l $victim" } { mypushmode $chan +l $CyProt::ProtectSetLimit; putcmdlog "Restore mode +l $CyProt::ProtectSetLimit" } } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-limit"]==-1} { lappend CyProt::Badnicks "$nick-limit" } } } {+i} { if {$CyProt::ProtectInvite==1} { mypushmode $chan -i $victim; set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-invite"]==-1} {lappend CyProt::Badnicks "$nick-invite"} } } {-i} { if {$CyProt::ProtectInvite==2} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { mypushmode $chan +i $victim } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-invite"]==-1} {lappend CyProt::Badnicks "$nick-invite"} } } {+c} { if {$CyProt::ProtectColor==1} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { mypushmode $chan -c $victim } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-invite"]==-1} {lappend CyProt::Badnicks "$nick-color"} } } {-c} { if {$CyProt::ProtectColor==2} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { mypushmode $chan +c $victim } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-invite"]==-1} {lappend CyProt::Badnicks "$nick-color"} } } {+C} { if {$CyProt::ProtectCTCP==1} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { mypushmode $chan -C $victim } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-invite"]==-1} {lappend CyProt::Badnicks "$nick-ctcp"} } } {-C} { if {$CyProt::ProtectCTCP==2} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { mypushmode $chan +C $victim } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-invite"]==-1} {lappend CyProt::Badnicks "$nick-ctcp"} } } {+k} { if {$CyProt::ProtectKey!=0} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { if {$CyProt::ProtectKey==1} { mypushmode $chan -k $victim } { foreach { keychan key } $CyProt::ProtectSetKey { if {$chan==$keychan} {mypushmode $chan +k $key} } } } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-key"]==-1} {lappend CyProt::Badnicks "$nick-key"} } } {-k} { if {$CyProt::ProtectKey!=0} { set usekey $victim; set nickcheck [CheckUser $hand $chan] if {$CyProt::ProtectKey==2} { foreach { keychan key } $CyProt::ProtectSetKey { if {$chan==$keychan} {set usekey $key} } } if {![lindex $nickcheck 1]} { if {$CyProt::ProtectKey==1} { mypushmode $chan +k $victim } { foreach { keychan key } $CyProt::ProtectSetKey { if {$chan==$keychan} {mypushmode $chan +k $usekey} } } } if {![lindex $nickcheck 0] && ![lindex $nickcheck 1]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } if {[lsearch $CyProt::Badnicks "$nick-key"]==-1} {lappend CyProt::Badnicks "$nick-key"} } } {+p} { if {$CyProt::ProtectSecret!=0} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { if {$CyProt::ProtectSecret==1} { mypushmode $chan -p } if {$CyProt::ProtectSecret==2} { mypushmode $chan -p; mypushmode $chan +s } if {![lindex $nickcheck 0]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } } } } {-p} { if {$CyProt::ProtectSecret!=0} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { if {$CyProt::ProtectSecret==1} { mypushmode $chan +p } if {$CyProt::ProtectSecret==2} { mypushmode $chan +s } if {$CyProt::ProtectSecret==3} { mypushmode $chan +p } if {![lindex $nickcheck 0]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } } } } {+s} { if {$CyProt::ProtectSecret!=0} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { if {$CyProt::ProtectSecret==1} { mypushmode $chan -s } if {$CyProt::ProtectSecret==3} { mypushmode $chan -s; mypushmode $chan +p } if {![lindex $nickcheck 0]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } } } } {-s} { if {$CyProt::ProtectSecret!=0} { set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { if {$CyProt::ProtectSecret==1} { mypushmode $chan +s } if {$CyProt::ProtectSecret==2} { mypushmode $chan +s } if {$CyProt::ProtectSecret==3} { mypushmode $chan +p } if {![lindex $nickcheck 0]} { if {$CyProt::KickOnMode} { putquick "KICK $chan $nick :WTF? Don't change any modes here!" } { putnotc $nick "WTF? Don't change any modes here!" } } } } } default { putcmdlog "MODE $nick!$uhost ($hand) $chan $mc $victim" } } #flushmode $chan; } proc Kick { nick uhost hand chan target reason } { global botnick botname; set Chan $chan; set chan [string tolower $chan]; if {[lsearch $CyProt::Channels $chan]==-1} {return} if {$nick==$botnick} {return} set time [clock seconds] if {$target==$botnick} { CyProt::AddBadUser $nick putlog "$nick kick me in $chan" putquick "JOIN $chan" putquick "PRIVMSG $CyProt::ServiceBot :op $chan" putquick "KICK $chan $nick :WTF, play somewhere other" lappend CyProt::Brain kick $nick $chan $time; } { # is not $botnick set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { CyProt::AddBadUser $nick if {$CyProt::KickOnKick} { putquick "KICK $chan $nick :WTF? Dont kick any other ppl!" } } } } proc Join { nick uhost hand chan } { global botnick botname; set chan [string tolower $chan]; if {[lsearch $CyProt::Channels $chan]==-1} {return} if {$nick!=$botnick} {return} set time [clock seconds] if {$nick==$botnick} { putquick "PRIVMSG $CyProt::ServiceBot :op $chan" } } proc Need { chan type } { global botnick botname; set chan [string tolower $chan]; if {[lsearch $CyProt::Channels $chan]==-1} {return} switch -exact -- $type { op { putquick "PRIVMSG $CyProt::ServiceBot :op $chan" } unban { putquick "PRIVMSG $CyProt::ServiceBot :unbanall $chan"; putserv "JOIN $chan" } invite { putquick "PRIVMSG $CyProt::ServiceBot :clearchan $chan"; putquick "PRIVMSG $CyProt::ServiceBot :invite $chan"; putserv "JOIN $chan" } limit { putquick "PRIVMSG $CyProt::ServiceBot :clearchan $chan"; putserv "JOIN $chan" } key { putquick "PRIVMSG $CyProt::ServiceBot :clearchan $chan"; putserv "JOIN $chan" } default { putcmdlog "Need $type in $chan" } } } proc Time { args } { set dest [list] set num "" foreach chan $CyProt::Channels { if [validchan $chan] { set num 0; foreach { WHAT NICK CHAN CREATED } $CyProt::Brain { putcmdlog "DEBUG CHAN $chan ? $CHAN , $WHAT : NICK $NICK , $CREATED" if {$CHAN==$chan} { set nothing 0 switch -exact -- $WHAT { kick {lappend dest $NICK} unban {mypushmode $chan -b $NICK {Unban Time Queue}} setkey {mypushmode $chan +k $NICK {Setkey Time Queue}} default {set nothing 1} } if !$nothing { set CyProt::Brain [lreplace $CyProt::Brain $num [expr $num+3]] incr num -4; } } incr num 4; } flushmode $chan } } if {$dest!=""} { foreach user [split $dest] { putquick "KICK $chan $user :WTF, play somewhere other" } putlog "regain op, kick $dest in $chan" } unset num dest; } proc Topic { nick uhost hand chan args } { global botnick botname; set Chan $chan; set chan [string tolower $chan]; if {[lsearch $CyProt::Channels $chan]==-1} {return} if {$nick==$botnick} {return} set time [clock seconds] # is not $botnick set nickcheck [CheckUser $hand $chan] if {![lindex $nickcheck 1]} { CyProt::AddBadUser $nick putlog "Topic Change: $nick ($nickcheck) Channel: [topic $chan] Args: $args" #if {$CyProt::KickOnTopic} # putquick "KICK $chan $nick :WTF? Dont kick any other ppl!" # } } set Devel 0; proc Rehash {} { set CyProt::Cmds [list addidiot addnick addident addhost] if {[info exist ::botnet-nick]} { if {${::botnet-nick}=="Devel"} { set CyProt::Devel 1 } } if {[info exist CyProt::Ver] && $CyProt::Devel} { set ver [split $CyProt::Ver .]; set ver [lreplace $ver 2 2 [expr [lindex $ver 2]+1]]; set CyProt::Ver [join $ver .]; putcmdlog "Rehashed to version $CyProt::Ver" } { putlog "CheckBot version $CyProt::Ver loaded" } return "$CyProt::Ver"; } ## binds bind mode - * CyProt::Mode bind kick - * CyProt::Kick bind join - * CyProt::Join bind need - * CyProt::Need bind time - * CyProt::Time bind topc - * CyProt::Topic bind pub m|o !badlist CyProt::pub_badlist bind pub m|o !badremove CyProt::pub_badremove bind pub m|o !badrem CyProt::pub_badremove bind pub m|o !baddel CyProt::pub_badremove bind pub m|o !badclear CyProt::pub_badclear #bind pub -|- !badclear CyProt::pub_badclear bind msg m|o !badlist CyProt::msg_badlist bind msg m|o !badremove CyProt::msg_badremove bind msg m|o !badrem CyProt::msg_badremove bind msg m|o !baddel CyProt::msg_badremove } ## init return [CyProt::Rehash]