That is because socket are asynchronous, they do not 'block' the execution of the script, when you call /follower inside the on text event, mIRC execute that alias and once that alias is done, moves on to the next thing, and the alias is only calling /sockclose & /sockopen, it's not setting the %follow variable, which is why %follow is empty.
You don't want to delay, you want to check for %follow once %follow is set.
The issue for beginner is "but how am I going to send a message to the channel from where %follow is set since i don't have $chan available?", and the answer is to just store the channel name.
There is, basically, a variable tied to the socket, you can use /sockmark <socket> <data> to store data tied to the socket.
Also, it looks like you only want the last line, you're using the on sockclose event for that, which is correct, but you should not use -f inside the on sockread, since it would read anything, even if it's not a line.
Try this:
alias follower {
sockclose follower
sockopen follower www.albinstuff.net 80
;$1 is $chan from the on text event, $2 is the nickname
sockmark follower $1-
}
on *:sockopen:follower: {
sockwrite -n follower GET /twitch2.php?id=user1&follows=user2 HTTP/1.0
sockwrite -n follower Host: www.albinstuff.net
sockwrite -n follower
}
on *:sockread:follower: {
var %read
sockread %read
}
on *:sockclose:follower: {
var %read
;makes $1 the channel and $2 the nickname
tokenize 32 $sock($sockname).mark
sockread -f %read
if (%read == true) {
msg $1 You are a follower $2
}
elseif (%read == false) {
msg $1 You are not a follower $2
}
else {
;you had $nick, previously, this is incorrect, mirc would try to evaluate "$nick,", you need $+ to concatenate
msg $1 Sorry $2 $+ , a error happen
}
}
on *:text:!follow:#: {
follower $chan $nick
}