Code: Select all
set url "http://www.lynxfm.info/stream.html"
set djtrigger "!dj"
set tracktrigger "!track"
set listenerstrigger "!listeners"
set alltrigger "!all"
set channel "#LynxFM"
### Current DJ ###
if {![info exists egghttp(version)]} {
putlog "egghttp.tcl was NOT successfully loaded."
putlog "shoutcast.tcl has not been loaded as a result."
} else {
proc current_dj {sock} {
global channel
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $body - dj
puthelp "PRIVMSG $channel :\0032\004The current DJ is: \0034$dj"
}
bind pub -|* $djtrigger top:djtrigger
proc top:djtrigger {nick host hand chan text} {
global url
set sock [egghttp:geturl $url current_dj]
return 1
}
### Current Track ###
proc current_track {sock} {
global channel
set headers [egghttp:headers $sock]
set body1 [egghttp:data $sock]
regexp {<td height="39" valign="top" id="song"><font color="white" face="verdana" size="2">(.*?)</font></td>} $body1 - track
puthelp "PRIVMSG $channel :\0032\004The current Track is: \0034 $track"
}
bind pub -|* $tracktrigger top:tracktrigger
proc top:tracktrigger {nick host hand chan text} {
global url
set sock [egghttp:geturl $url current_track]
return 1
}
### Current Listeners ###
proc current_listeners {sock} {
global channel
set headers [egghttp:headers $sock]
set body2 [egghttp:data $sock]
regexp {<td height="21" valign="top" id="listeners"><font color="white" face="verdana" size="2">(.*?)</font></td>} $body2 - listeners
puthelp "PRIVMSG $channel :\0032\004Current Listeners: \0034 $listeners"
}
bind pub -|* $listenerstrigger top:listenerstrigger
proc top:listenerstrigger {nick host hand chan text} {
global url
set sock [egghttp:geturl $url current_listeners]
return 1
}
### All Stats ###
proc show_all {sock} {
global channel
set headers [egghttp:headers $sock]
set all1 [egghttp:data $sock]
set all2 [egghttp:data $sock]
set all3 [egghttp:data $sock]
regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $all1 - dj
regexp {<td height="39" valign="top" id="song"><font color="white" face="verdana" size="2">(.*?)</font></td>} $all2 - track
regexp {<td height="21" valign="top" id="listeners"><font color="white" face="verdana" size="2">(.*?)</font></td>} $all3 - listeners
puthelp "PRIVMSG $channel :\0032\004Current Status:\n \0034 The current DJ is:$dj \n The current track is: $track \n With listeners: $listeners"
}
bind pub -|* $alltrigger top:alltrigger
proc top:alltrigger {nick host hand chan text} {
global url
set sock [egghttp:geturl $url show_all]
return 1
}
putlog "shoutcast.tcl has been successfully loaded."
}