on 1:TEXT:!onair:#: {
; Server of your station (use network name of computer, or ip)
/set -u0 %sc.server www.nappybase.com
; port of server
/set -u0 %sc.port 8000
if (%sc.chan == $null) {
/set %sc.chan $chan
/sockopen shoutcast %sc.server %sc.port
/msg $chan Querying Server... Please Wait.
; stop connectiong from getting "hung up"
.timerscast 1 30 /sc.timeout
}
else { /msg $chan Server Is Being Queried. Please Wait }
}
on 1:SOCKOPEN:shoutcast: {
if ($sockerr) {
; There was an error
/set %sc.status Server is currently Down.
}
else {
; Write To The Socket
/sockwrite -n $sockname GET /7.html HTTP/1.1
/sockwrite -n $sockname Accept: */*
/sockwrite -n $sockname Accept-Language: en-us
/sockwrite -n $sockname Accept-Encoding: gzip, deflate
/sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
/sockwrite -n $sockname Host: $sock($sockname).ip $+ :80
/sockwrite -n $sockname Connection: Keep-Alive
/sockwrite -n $sockname $crlf
}
}
on 1:SOCKREAD:shoutcast: {
; Read The Buffer
/sockread -f 5000 &shoutcast
/bwrite shoutcast.txt -1 -1 &shoutcast
}
on 1:SOCKCLOSE:shoutcast: {
if (%sc.chan != $null) {
/set -u0 %sc.read $remove($read(shoutcast.txt, 4), <HTML><meta http-equiv="Pragma" content="no-cache"></head><body>, </body></html>)
; get Information
if (%sc.status == $null) { /set %sc.status $iif($gettok(%sc.read, 2, 44) == 0, Server Is Currently Down, Server Is Currently Up) }
; Message Channel Status
if (down isin %sc.status) { /msg %sc.chan Server Status: %sc.status }
else {
/set %sc.song $gettok(%sc.read, 7, 44)
/msg %sc.chan Server Status: %sc.status - Current Song: %sc.song
}
; Clear Used Variables
/unset %sc.*
}
.remove shoutcast.txt
}
alias sc.timeout {
/msg %sc.chan Server has timed out. Please try again later.
/unset %sc.*
}