I've been trying to wrap my head around this for hours now. I have wrote a complex Twitch Autohost script that is almost completely functional except for this last piece of the puzzle. The issue I am having is that it appears as if variables are not being set/returned fast enough. This is the "checking if channel is live" portion of my autohost script (I got the template on this forum). The issue is that the other portion of my script is quickly scanning each channel in my autohost list in a while loop, and needs to know right away if a channel is live so it can do the hosting and then halt the while loops that keep searching for a channel to host before it tries to host another. The issue in this code is that the "
IF (%tuptime == True) { return true }" line of
tuptime does not actually return "true" fast enough, as when I used the "!ahtest channelname" in the script show, it will not msg channel until the second time that I run it, which it will then return both "test2" and then "test1" to the channel. However, the %tuptime variable IS getting set in mIRC immediately after I first use the !ahtest command. My question is, how can I have my tuptime alias start and then finish and return true before the tuptime alias is called on again in the while loops I have created in the rest of my script that I have written?
ON *:TEXT:!ahtest &:#: {
$tuptime($2)
IF (%tuptime) MSG $chan test1
}
alias tuptime {
SET %uptimechan $1
sockclose tuptime
sockopen tuptime nightdev.com 80
IF (%tuptime == True) { msg $chan test2 | return true }
}
ON *:SOCKOPEN:tuptime: {
if ($sockerr) { sockclose $sockname | halt }
sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ %uptimechan HTTP/1.1
sockwrite -n $sockname Host: $sock($sockname).addr
sockwrite -n $sockname $crlf
}
ON *:SOCKREAD:tuptime: {
if ($sockerr) { sockclose $sockname }
var %data
sockread %data
if ($gettok(%data,1,32) isnum) && ($gettok(%data,2,32)) {
SET %tuptime True
}
}