TCL Mode Protection

Mode Protection

bind raw - MODE newmode_on
proc newmode_on { from key args } {
	global botnick
	set args [lindex $args 0]
	set mode_chan [lindex $args 0]
	set the_mode [lindex $args 1]
	set mode_args [lindex $args 2]
	scan $from "%\[^!]@%s" unick uhost
	set who_user [finduser $from]
	if {$who_user == $botnick} {return 0}
	if {$the_mode == "+d"} {
		if { [matchattr $who_user n|n $mode_chan] } {return 0}
		putserv "MODE $mode_chan -o $unick"
		putserv "MODE $mode_chan +b $unick"
		putserv "KICK $mode_chan $unick :Don't put +d bud.."
		putserv "MODE $mode_chan -d $mode_args"
		adduser $unick $unick!*@*
		chattr $unick -fopmtxh+dk
		setuser $unick xtra Added "Denied modes!"
	}
	if {$the_mode == "+e"} {
		if { [matchattr $who_user n|n $mode_chan] } {return 0}
		putserv "MODE $mode_chan -o $unick"
		putserv "MODE $mode_chan -e $mode_args"
		putserv "MODE $mode_chan +b $unick" 
		putserv "KICK $mode_chan $unick :Don't put +e bud.."
		adduser $unick $unick!*@*
		chattr $unick -foptjxhm+d
		setuser $unick xtra Added "Denied modes!"
	}
}
putlog "Protection +d & +e loaded"