Code: Select all
proc pub:add {nick host hand chan arg} {
global botnick user
set level [lindex $arg 0]
set args [lrange $arg 1 end]
You realize your failing to split the string 'arg' before applying the list index command on it. What will happen with nicknames that contain braces?
Code: Select all
<speechles> .tcl set test "{joe}"
<bot> Tcl: {joe}
<speechles> .tcl set c [lindex $test 0]
<bot> Tcl: joe
<speechles> .tcl set test "{joe"
<bot> Tcl: {joe
<speechles> .tcl set c [lindex $test 0]
<bot> Tcl error: unmatched open brace in list
<speechles> .tcl set test "{joe}away"
<bot> Tcl: {joe}away
<speechles> .tcl set c [lindex $test 0]
<bot> Tcl error: list element in braces followed by "away" instead of space
The first example above shows that the nickname will not be correct, the braces are omitted. The second example shows that the script will bail (crash out). The third example also bails with a different error. This is caused by not using the command [split] when dealing with string input derived from binds.
Code: Select all
set level [lindex [split $arg] 0]
set args [lrange [split $arg] 1 end]
This would be the proper and correct way to avoid these types of problems. You should look into properly coding your scripts so others using it can actually have it function correctly when nicknames contain braces. You will surely have people complain that nicknames containing any braces break your scripts...