TCL Clear channel

Clear channel

# CLEARCHAN 1.0 by TX
#
# Syntax: /msg Nick clearchan <#channel>
# Using this command will clear all:
#  * Modes
#  * Ops
#  * Voices
#  * Bans
#
# You need to set up the binds yourself, k? It's set up as a /msg
# right now :)
#
# Help gladly given with this script, catch me on Undernet, nickname TX
# or e-mail aspworld@thirdfloor.net
#
# Good luck!

bind msg n clearchan pub:clearchan

proc pub:clearchan {nick uhost hand arg} {
   set arg1 [lindex $arg 0]
   if {[string match #* $arg1]} {
   pushmode $arg1 -n
   pushmode $arg1 -s
   pushmode $arg1 -m
   pushmode $arg1 -c
   pushmode $arg1 -t
   pushmode $arg1 -p
   pushmode $arg1 -i
   pushmode $arg1 -l
   pushmode $arg1 -k *
   set chanlist [chanlist $arg1]
   foreach o $chanlist {
     if {[isop $o $arg1]} {
	global botnick
	if {$o == $botnick} { set blah "nothing" 
        } else { 
        pushmode $arg1 -o $o
        }
     } else {
        set blah "+nothing"
     }
   }
   foreach v $chanlist {
     if {[isvoice $v $arg1]} {
	global botnick
	if {$v == $botnick} { set blah "nothing" 
        } else { 
        pushmode $arg1 -v $v
        }
     } else {
        set blah "+nothing"
     }
   }
   foreach ban [chanbans $arg1] {pushmode $arg1 -b [lindex $ban 0]}
    set clearkey [getkey $arg1]
    if {$clearkey == ""} {
       set blah "blah"
    } else {
       puthelp "MODE $arg1 -k $clearkey"
    }
   flushmode $arg1
   putcom $arg1 $nick "CLEARCHAN $arg1"
   } else {
   global botnick
   notice $nick "$arg1 is not a valid channel. Use /msg $botnick help clearmode for more help."
   }
   putlog "Clearchan 1.0 by TX loaded."
}