#--------------------------------------------------------------------- # prot-deop.tcl # TCL script for IRC bot eggdrop # With this script the bot will revenge deops (mode -o) in case: # 1. the deopper doesn't have certain flags # AND # 2. the victim does have certain flags # # v0: 24-Aug-1998 # v1: 02-Nov-1998 # v2: 18-Mar-2002 # - some upgrading :) #--------------------------------------------------------------------- #--------------------------------------------------------------------- # Handles having one of the global flags in "deopprotglobflag" or # one of the channel flags in "deopprotchanflag" are allowed to deop # and are revenged in case of a deop. #--------------------------------------------------------------------- set deopprotglobflag "n m o f" set deopprotchanflag "n m o f" #--------------------------------------------------------------------- # The last kick is timestamped in the format $nick$channel[unixtime] # If a luser does something like -o+o-o on a protected user, two # kicks are send out if stamping is not used. #--------------------------------------------------------------------- set deopprotstamplastkick "" bind mode - * protect_deop proc protect_deop {nick uhost handle chan args } { global botnick deopprotglobflag deopprotchanflag #----------------------------------------------------------- # Check if it is a deop #----------------------------------------------------------- set modechange [join $args] if {[scan $modechange "-o %s" victim] != 1} { return } #----------------------------------------------------------- # For all actions (REOP and KICK) the bot must be op # The channel flag +protectops defines action #----------------------------------------------------------- if {![botisop $chan]} {return 0} set chaninfo [channel info $chan] if {[lsearch -exact $chaninfo -protectops] != -1} { return } #----------------------------------------------------------- # A fake deop is not revenged and also not reopped. # note: old egg versions use [isop], around 1.4 [wasop]. #----------------------------------------------------------- if {![wasop $victim $chan]} { return 0 } #----------------------------------------------------------- # Get the handle for the victim # If there is no handle: return # If the deopper is the bot: return #----------------------------------------------------------- set victimhandle [nick2hand $victim $chan] if {![validuser $victimhandle]} { return 0 } if {$nick==$botnick} { return 0 } #----------------------------------------------------------- # If a handle exists check for the flags. # A user with the deopprotglobflag or # deopprotchanflag is allowed to deop #----------------------------------------------------------- if {[validuser $handle]} { foreach exceptionflag $deopprotglobflag { if [matchattr $handle $exceptionflag] {return 0} } foreach exceptionflag $deopprotchanflag { if [matchchanattr $handle $exceptionflag $chan] {return 0} } } #----------------------------------------------------------- # Revenge if the victim is in the database with any of # the flags, # Fake deops (deopping someone with no ops) is handled # at the beginning. #----------------------------------------------------------- foreach exceptionflag $deopprotglobflag { if {[matchattr $victimhandle $exceptionflag]} { protdeoprevenge $nick $chan $victim $victimhandle return 1 } } foreach exceptionflag $deopprotchanflag { if {[matchchanattr $victimhandle $exceptionflag $chan]} { protdeoprevenge $nick $chan $victim $victimhandle return 1 } } return 0 } #--------------------------------------------------------------------- # The revenge part # Note: there is no need to reop, because it was already checked # that channel is +protectops i.e. eggdrop should do the reop. #--------------------------------------------------------------------- proc protdeoprevenge {nick chan victim victimhandle} { global deopprotstamplastkick set stampnickchantime "$nick $chan [unixtime]" if {![string match $deopprotstamplastkick $stampnickchantime]} { putserv "KICK $chan $nick :Don't mess with my friends" putlog "PROTDEOP revenge: kicking $nick" set deopprotstamplastkick $stampnickchantime } #----------------------------------------------------------- # reop the victim # +o flagged users are handled by +protectops #----------------------------------------------------------- #if {![matchattr $victimhandle o] && # ![matchchanattr $victimhandle o $chan]} { # putserv "MODE $chan +o $victim" #} } putlog "Loaded (version 2): Deop protection."