proc setdj {nickname djnickname } {
if {$djnickname == "" } { set djnickname $nickname }
global streamip streamport streampass
putlog "shoutcast: new dj: $djnickname ($nickname)"
set temp [open "dj" w+]
puts $temp $djnickname
close $temp
set temp [open "djnick" w+]
puts $temp $nickname
close $temp
putserv "privmsg $nickname :your are now dj of this radio"
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0 } else {
puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
puts $sock "Host: $streamip"
puts $sock "Connection: close"
puts $sock ""
flush $sock
while {[eof $sock] != 1} {
set bl [gets $sock]
if { [string first "standalone" $bl] != -1 } {
set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
}}
if { $streamstatus == "1" } { poststuff privmsg "$djnickname is now rocking the turntables, enjoy." } else {
putserv "privmsg $nickname :this has not been announced because the radio is currentlfy offline." }
}}
