menu channel {
Radio Test
.Set Channel: { set %radiotest.room $$?="Full Channel Name" }
.$iif($timer(.radiotest),$style(2)) Turn On: { radiotest | .timer.radiotest 0 10 radiotest | echo -a radiotest msg on }
.$iif(!$timer(.radiotest),$style(2)) Turn Off: { unset %radiotest.song | unset %radiotest.lastsong | .timer.radiotest off | echo -a radiotest msg off }
}
alias radiotest { sockclose radiotest | sockopen radiotest s32.myradiostream.com 8104 }
on *:sockopen:radiotest: {
sockwrite -n $sockname GET /7.html HTTP/1.0
sockwrite -n $sockname User-Agent: SHOUTcast Song Status (Mozilla Compatible)
sockwrite -n $sockname Host: $+(s32.myradiostream.com,:,8104)
sockwrite -n $sockname $crlf
}
on *:sockread:radiotest: {
if ($sockerr > 0) return
var %radiotest | sockread -fn %radiotest
if ($regex(%radiotest,/<body>(.*)<\/body>/)) {
set %radiotest.song $gettok($regml(1),7-,44)
if (%radiotest.song != %radiotest.lastsong) {
msg %radiotest.room Now playing on Radio - %radiotest.song
set %radiotest.lastsong %radiotest.song
}
}
}