#--------------------------------------------------------------------- # badnickchange.tcl # TCL script for IRC bot eggdrop # # Assume the bot has a ban like "sex*!*@*" in its banlist. If a # matching nick!user@host joins a channel, the bot will place the ban # and kick the user. If a nick already is on a channel, changes # its nick and matches the ban, by default nothing happens. # Upon a nick change, this script rechecks the global and channel # banlist for a match with the new nick!user@host and kicks if a # match is found. # If a ban exists on the channel which is not in the internal # global/channel banlist, there is no kick. # Channel set must include: +enforcebans! # Exempted: bot and a known user with global/channel flags (n/m/o/f) # # v0: 27-Mar-2002 # v1: 28-Mar-2002 # + include check for current channel bans #--------------------------------------------------------------------- package require eggdrop 1.6 package require Tcl 8.0 bind nick - * badnickchange proc badnickchange { nick uhost hand chan newnick } { global botnick # in case bot must kick, bot needs op if { ![botisop $chan] } { return } # if channelsetting is -enforcebans, omit the remainder... set chaninfo [channel info $chan] if {[lsearch -exact $chaninfo -enforcebans] != -1} { return } # check for exempts if { [string compare $newnick $botnick] == 0 } { return } if { [validuser $hand] } { foreach flag "n m o f" { if {[matchattr $hand $flag]} { return } if {[matchchanattr $hand $flag $chan]} { return } } } # No exempts. # Compare the nuhost with three types of bans: # 1. current bans on the channel # 2. global bans in the bots internal banlist # 3. channel bans in the bots internal banlist set nuhost $newnick!$uhost # # check current bans on the channel # foreach banmask [chanbans $chan] { # if { [string match $banmask $nuhost] != 1 } { continue } # set bancomm "Banned! ($nuhost matches ban $banmask)" # putserv "KICK $chan $nick :$bancomm" # return # } # global bans in the bots internal banlist foreach ban [banlist] { set banmask [lindex $ban 0] if { [string match $banmask $nuhost] != 1 } { continue } set bancomm [lindex $ban 1] putserv "KICK $chan $nick :$bancomm" return } # channel bans in the bots internal banlist foreach ban [banlist $chan] { set banmask [lindex $ban 0] if { [string match $banmask $nuhost] != 1 } { continue } set bancomm [lindex $ban 1] putserv "KICK $chan $nick :$bancomm" return } } putlog "Loaded (version 0): Badnickchange."