Code: Select all
bind raw - 311 raw:qauth
#Proc has been declared with an "args" parameter, yet the raw binding always calls the proc with a fixed number of arguments.. Hence, args will be a tcl-list with one list-item containing all that the server sent us...
proc raw:qauth {from keyword args} {
global Qauth Qpass Qhost
#Since args is a list, we have to use join to convert it into a string. Using a different parameter name would save us from this extra work...
set args [string tolower [join $args]]
#But now, we've already converted args into a string, we can't use list operations on it, such as lindex...
#Even if we hadn't joined args into a string, you'd still have problems, as the initial list only had one list item containing the whole string, and all you'd end up with is having nick = "" and host = "@".
#What you need to do, is convert the string into a list. split usually does the trick here, and it also allows you to specify which character (default space) should be used to "split" upon.
set nick [lindex $args 1]
set host "[lindex $args 2]@[lindex $args 3]"
if {$host == [string tolower $Qhost]} {
puthelp "PRIVMSG Q@CServe.quakenet.org :AUTH $Qauth $Qpass"
#Here we try to read the local variable gatherbot, yet it has not been declared anywhere within the proc, thus this will throw an error and abort execution...
#Most likely, you were trying to access the globalspace variable with the same name. To do this, you'd either have to use the global command, or use a full path to the variable ($::gatherbot)
puthelp "PRIVMSG $gatherbot :AUTH"
}
}
### The proper code should look something like this instead:
bind raw - 311 raw:qauth
proc raw:qauth {from keyword text} {
global Qauth Qpass Qhost
set ltext [split $text]
set nick [lindex $ltext 1]
set host "[lindex $ltext 2]@[lindex $ltext 3]"
#I am using a slightly different way of comparing the hosts, saving me alot of case mangling.
if {[string equal -nocase $host $Qhost]} {
puthelp "PRIVMSG Q@CServe.quakenet.org :AUTH $Qauth $Qpass"
puthelp "PRIVMSG $::gatherbot :AUTH"
}
}