TCL Bot die

Bot die

# DiePass By Wcc and Nilsy	
# This script makes owners (+n users) to enter a password to use ".die".
# This also disables /msg <bot> die. Thanks to Nilsy on undernet for all the help.

set pass "pass"

# Would you like to log all die attempts with invalid passwords?
set useinfo "1"

# Set the channel or nick to private message when an attempt is made. (Only if useinfo is enabled)
set infodest "Beliata"

set failmsg "Invalid password!"

bind dcc n|- die dcc:die
unbind msg n|- die *msg:die

proc dcc:die {hand idx text} {
	global useinfo infodest failmsg pass
	if {$text == ""} {
		putidx $idx "Usage: die <password> \[reason\]"
		return 0
	}
	set chkpass [lindex $text 0]
	if {$chkpass == $pass} { 
		if {[llength $text] > 1} {
			set reason [lrange $text 1 end]
		} else {
			set reason "Authorized by $hand"
		}
		die $reason 
		return 1
	} else {
		putidx $idx "Invalid die password, attempt has been logged."
		if {$useinfo == 1} { 
			puthelp "PRIVMSG $infodest :DIEPASS: $hand $failmsg."
			putlog "DIEPASS: $hand just tried to issue a .die command with the invalid password \"$chkpass\" "
			return 0
		} 
		return 0
	}
}
putlog "DiePass by Beliata"