@Get_A_Fix:
If you're really going to thrash down on a new poster like that, you really should atleast get your own code/facts straight (and no, I don't encourage thrashing down on users).
First of all, your posted example is using recursive code in a flawed manner.
Secondly, within auth_check, there exists no local variable "chan", so your puthelp's will throw an error.
Now, some code that should get you started atleast:
Code: Select all
bind pub - ".signup" ofm:signup
bind raw - 307 handleAuth
array set authUsers ""
proc ofm:signup {nick host handle channel text} {
set ::authUsers([string tolower $nick]) [list 0 $channel [unixtime]]
putserv "WHOIS $nick"
}
proc handleAuth {from keyword text} {
set index [string first " " $text]
set nick [string range $text 0 $index]
set lnick [string tolower $nick]
set rest [lindex [split text ":"] end]
if {[info exists ::authUsers($lnick)]} {
set channel [lindex $::authUsers($lnick) 1]
if {[string match "*is a registered nick*" $rest]} {
set ::authUsers($lnick) [list 1 $channel [unixtime]]
puthelp "NOTICE $channel :verified - ok to keep going"
} else {
unset ::authUsers($lnick)
puthelp "NOTICE $channel :unverified - we need to stop here"
}
}
#Always return 0 so we don't break other things relying on 307 response.
return 0
}
The above code is a bare skeleton for making these asynchronous flows working.
A short explanation;
I use a global array to keep track of the different requests being made. Each item in the array is identified by the nickname (in lowercase), and contains a list of data - a boolean (0/1) whether the user has been verified, the channel from which the request was issued, and a timestamp of the latest update.
The first can be used for future lookups (caching), with the help of the timestamp to decide if it's still valid or not.
The second is used in the authCheck function to know where to send the response.
authCheck will check that there is a request in progress for the current server reply. If not, the response will be silently ignored.
The first few lines of authCheck shows different ways of extracting the server response into separate variables. Once the request have been found in the array, the channel name is also extracted.