# This script bans users which joins a given channel within 5 seconds # after getting kicked, for 5 minutes. Made for eggdrop v1.1 # # V1.1c, written by Anders Nordby aka. nickerne (anders@fix.no) # # 1.0a: Small bugfix. # 1.0b: Included flag-based exception from banning. # 1.0c: Registering channel-bans was a stupid thing. Speeded things up a # little. Also made the flag-based ban-exception host specific (instead # of nick specific). And some other changes, like the nick/host flag. # 1.1: Several fixes: # # * maximum one kick for autorejoining, if the ban fails. # * fixed bug with 10 characters in the username (ban failed) # * added nar_multichannel option # * bans with the same hostname won't be cleared more than once # 1.1b: Users with the dontban-flag on the bot got kicked if they had the # wrong nick. Fixed. # 1.1c: Fixed problems with people using nicks having troublesome characters. # delay before users can join the channel after a kick (in seconds) set nar_joindelay 5 # the bans will be removed after this delay (in minutes) set nar_bantime 1 # 0=work on one channel only, 1=multichannel (overrides channel-setting) set nar_multichannel 0 # the channel you wish this script to work on --- #cybex set nar_channel "#cybex.test #tcl #izno #bastis" # do not ban users with this flag on the bot set nar_dontban "Z" # 1=nick&host-specific bans, 0=host-specific bans set nar_nickban 0 bind kick - * autorejoin_ban # bind join - * autorejoin_ban proc autorejoin_ban {nick uhost hand chan knick reason} { global nar_joindelay nar_channel nar_multichannel #putcmdlog "AJ_ban: nick $nick kick knick $knick in $chan" #if {$nick==$::botnick || $knick==$::botnick} {return} #putcmdlog "rejoined" #putcmdlog "-1- if !expr" if {[string equal -nocase "Sir, you seem to be a trojan drone. Just rejoin if that is not the case." $reason]} { putlog "ignore kick $knick from $nick in $chan, trojan reason" return } putcmdlog "check onchan $knick #tcl.intern [onchan $knick #tcl.intern]" if {[onchan $knick #tcl.intern]} { putlog "ignore kick $knick from $nick in $chan, is in #tcl.intern" return } if {![expr [lsearch -glob [utimers] "*nada \{$knick\} \{$chan\}*"] + 1]} { #putcmdlog "-1-- if multichan" if {$nar_multichannel} { #putcmdlog "-1--- utimer" putlog "Oh, $nick kicked $knick :-)" if {[matchattr $hand bfmnvo|mnov $chan]} { utimer $nar_joindelay [subst {kickban_when_autorejoined {$knick} {$chan} }] } } else { #putcmdlog "-1--- foreach" foreach chans $nar_channel { #putcmdlog "-1---- if chan $chan == $chans" if {$chan == $chans} { putlog "Oh, $nick kicked $knick :-)" #putcmdlog "-1----- if matchattr $hand bfmnvo|mnov $chan == [matchattr $hand bfmnvo|mnov $chan]" #if {[matchattr $hand bfmnvo|mnov $chan] || $nick==$::botnick} #putcmdlog "-1------ utimer" for {set tick 1} {$tick<=$nar_joindelay} {incr tick 2} { utimer $tick [subst {kickban_when_autorejoined {$knick} {$chan} }] } utimer [expr 2+$nar_joindelay] [list pushmode $chan -v $knick] #putcmdlog "-1----- endif" } #putcmdlog "-1---- endif" } #putcmdlog "-1--- endforeach" } #putcmdlog "-1-- endif" } #putcmdlog "-1- endif" #putcmdlog [utimers] } proc kickban_when_autorejoined {nick chan } { global nar_bantime nar_dontban nar_nickban nar_joindelay #putcmdlog "-2- if onchan" if {$nick==$::botnick} {return} puthelp "MODE $chan +v $nick" if {[onchan $nick $chan]} { #putcmdlog "-2-- if matchattr" putlog "and $nick rejoin .." if {[matchattr [nick2hand $nick $chan] $nar_dontban] || [matchattr [nick2hand $nick] b]} { #putcmdlog "-2--- puthelp" puthelp "PRIVMSG #cybex.test :$nick will not be banned, of course, as he has +$nar_dontban." } else { #putcmdlog "-2--- set host" set hostmask [getchanhost $nick $chan] #putcmdlog "-2--- set host2" set hostmask "$nick!$hostmask" #putcmdlog "-2--- putquick ban" putquick "MODE $chan +b $hostmask" #putcmdlog "-2--- utimer nada" utimer [expr 2 * $nar_joindelay] [subst {nada {$nick} {$chan} }] #putcmdlog "-2--- putquick kick" putquick "KICK $chan $nick :You autorejoined after getting kicked. Not that smart indeed." #putcmdlog "-2--- if !expr" if {![expr [lsearch [utimers] "*mode $chan -b \{$hostmask\}*"] + 1]} { #putcmdlog "-2---- utimer mode" utimer [expr 60 * $nar_bantime] [subst {pushmode {$chan} -b {$hostmask} }] } #putcmdlog "-2--- puthelp notice" puthelp "notice $nick :Somebody kicked you, and you autorejoined. $nar_bantime minutes in the corner! Turn off autorejoin!" } } #putcmdlog [utimers] } proc nada {nick chan} { #putcmdlog [utimers] } putlog "NO! autorejoin v1.2a by nickerne - optimized by CyBex"