#--------------------------------------------------------------------- # listbindings.tcl # TCL script for IRC bot eggdrop # Writes out current bindings to a file "bindings.txt". # # dcc usage: .listbinds # # In the configuration file of eggdrop several bind/unbinds are # described. This script attempts to list more bindings for review # and, possibly, unbinding. # # Upon typing ".listbinds" on the partyline, this script writes out # all bindings to a file (bindings.txt) # # An option is to copy the file to bindings.tcl, review and edit that # file to unbind commands and load it on the bot. # To unbind a command: remove the "#" at the beginning of the line. # # v0: 20-Mar-2002 # v1: 22-Mar-2002 #--------------------------------------------------------------------- package require eggdrop 1.6 package require Tcl 8.0 bind dcc n listbinds listbindings proc listbindings { hand idx arg } { # BEGIN set filename bindings.txt putlog "Listing bindings to file: STARTED" set bindlist [binds] # initialize the width for { set indx 0 } { $indx <= 2 } { incr indx } { set w($indx) 0 } # determine the maximum length for type/flag/name foreach binding $bindlist { set indx 0 while { $indx <= 2 } { set item [lindex $binding $indx] # newer tcl versions have [string bytelength].... set width [string length $item] if {$width > $w($indx)} { set w($indx) $width } # increment incr indx } } # increment the text width by 2 for { set indx 0 } { $indx <= 2} { incr indx } { incr w($indx) 2} # format set format "%-$w(0)s %-$w(1)s %-$w(2)s %-s" # open file (destroys/overwrites previous file) set fileid [open $filename w] puts $fileid { #--------------------------------------------------------------------- # bot bindings. # Some bindings -appearantly- can not be unbound. #--------------------------------------------------------------------- } # write out the bindings foreach binding $bindlist { set bindtype [lindex $binding 0] set bindflag [lindex $binding 1] set bindname [lindex $binding 2] set bindhits [lindex $binding 3] set bindproc [lindex $binding 4] set string [format $format $bindtype $bindflag $bindname $bindproc] puts $fileid "#unbind $string" } puts $fileid {putlog "Unbindings version 0 loaded"} close $fileid putlog "Listing bindings to file: FINISHED" # END } putlog "Loaded (version 0): Listbindings."