####################################
### NoTriggers.tcl		 ###
### Version 1.1			 ###
### By Wcc			 ###
### irc.dal.net			 ###
####################################

################################################################################################
## This script warns users if they type a list trigger in the channel. It kicks on the second ##
## offense, bans on the third.								      ##
################################################################################################

##########################################################
## Just load the script, set the variables, and rehash. ##
##########################################################

#################################################################
# Set the channel you DONT want users to type triggers in here. #
#################################################################

set notrigchan "#channel"

###############################################
# What channel should users goto for servers? #
###############################################

set serverchan "#serverchan"

####################
# Code begins here #
####################

bind pub - !list checklist
bind pub - @find checklist
bind pub - @locator checklist

if {[array exists bp]} {
	unset bp
	putlog "NOTRIGGERS: Cleaning trigger array."
}

proc checklist {nick uhost hand chan text} {
	global bp botnick notrigchan serverchan
	set lchan [string tolower $chan]
	set mask *!*[string trimleft [maskhost $uhost] !*~+-]
	set name $lchan!$mask
	if {![info exists bp($name)]} {
		set bp($name) 0
	}
	if {([string tolower $chan] == $notrigchan) && ([botisop $chan])} {
		if {$bp($name) == 0} {
			puthelp "PRIVMSG $chan :$nick, please do not use triggers in this channel. Our servers are in $serverchan."
			incr bp($name)
			return 0
		} elseif {$bp($name) == 1} {
			puthelp "KICK $chan $nick :Please do not use triggers in this channel. Our servers are in $serverchan. The next time you type a trigger, you will be banned."
			incr bp($name)
		} else {
			newchanban $chan $mask $botnick "Please do not use triggers in this channel. Our servers are in $serverchan. You have been banned for 5 minutes." 5
			puthelp "KICK $chan $nick :Please do not use triggers in this channel. Our servers are in $serverchan. You have been banned for 5 minutes."
			unset bp($name)
		}
	}
}		
    
putlog "NOTRIGGERS: NoTriggers.tcl by wcc is loaded."
putlog "NOTRIGGERS: No triggers are allowed in $notrigchan."
putlog "NOTRIGGERS: Server channel is $serverchan."