TCL Nick completion

Nick completion

# NickComp.Tcl -- botnet nick completion
# by k-no <keith@cs.oswego.edu>
# cleaned it up a bit for eggdrop 1.3 (David Newhall <david@sleepers.net>)
# enjoy!
# Set the format string below to what your output should look like.
# &n = nick completed
# &t = text
###################################################################
set format_nick_comp "&n: &t"

bind filt -|- "%: *" nick:comp

proc nick:comp {idx vars} {
 global format_nick_comp
 if {[string index $vars 0] == "."} {return}
 set x [whom [getchan $idx]]
 set list ""
 foreach i $x {lappend list [lindex $i 0]}
 set nick [string trimright [lindex $vars 0] :]
 set list [lsort $list]
 set niq $nick
 foreach i $list {
  if {[string match [string tolower $nick]* [string tolower $i]]} {
   set niq $i
   break
  }
 }
 regsub -all &n ${format_nick_comp} $niq newniq
 regsub -all &t $newniq [lrange $vars 1 end] newniq
# dccsimul $idx $newniq
 return [join $newniq]
}