I want to write a simple socket to go with a !uptime command for a bot I'm running for a twitch stream. I've looked at multiple different examples of how to write a socket but nothing seems to be working. My code looks like this:
on *:TEXT:!uptime*:#:{
sockclose utSocket
sockopen utSocket www.nightdev.com 80
}
on *:sockopen:utSocket:{
if ($sockerr) { sockclose utSocket | halt }
sockwrite -n utSocket GET /hosted/uptime.php?channel=STREAM_NAME HTTP/1.1
sockwrite -n utSocket Host: www.nightdev.com
sockwrite utSocket $crlf
}
on *:sockread:utSocket:{
var %read
sockread -f %read
msg # Stream has been running for %read .
sockclose utSocket
}
www.nightdev.com/hosted/uptime.php?channel=STREAM_NAME will just display text of the running time of whatever stream is put in the URL in place of STREAM_NAME, which is exactly what I want.
Does anyone know what the problem is? Is there anything else that needs to be done when making a socket or am I missing something here?