This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Quick question regaurding timers..

Help for those learning Tcl or writing their own scripts.
Post Reply
r
rpope904
Voice
Posts: 16
Joined: Sat Feb 02, 2008 7:41 pm

Quick question regaurding timers..

Post by rpope904 »

I am trying to modify an existing script, right now it requires the command !song to be typed in the channel, I want to change it to just display the current song every 5 minutes.. the code is:

bind pub -|- !song get_shoutcast_song
bind pub -|- !np get_shoutcast_song
proc get_shoutcast_song {nick uhost hand chan arg} {
global url streamch
set streamch [string tolower $streamch]
::http::config -useragent "Mozilla/5.0; Shoutinfo"
if {[string tolower $chan] == "$streamch"} {
set http_req [::http::geturl $url -timeout 2000]
if {[::http::status $http_req] != "ok"} {
puthelp "PRIVMSG $chan :Stream is unavailable";
}
set data [::http::data $http_req]
::http::cleanup $http_req
if {[regexp {<font class=default>Current Song: </font></td><td><font class=default><b>([^<]+)</b>} $data x title]} {
puthelp "PRIVMSG $chan :\002Current Song\002: $title"
} else {
puthelp "PRIVMSG $chan :Couldn't receive any information, checking server status..."
get_shoutcast_server $nick $uhost $hand $chan $arg
}
}
}



Any help is appreciated :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind time - "?0 *" display:song
bind time - "?5 *" display:song

proc display:song args {
 global url streamch
 set streamch [string tolower $streamch]
 ::http::config -useragent "Mozilla/5.0; Shoutinfo"
 set http_req [::http::geturl $url -timeout 2000]
 if {[::http::status $http_req] != "ok"} {
  puthelp "PRIVMSG $streamch :Stream is unavailable";
 }
 set data [::http::data $http_req]
 ::http::cleanup $http_req
 if {[regexp {<font class=default>Current Song: </font></td><td><font class=default><b>([^<]+)</b>} $data x title]} {
  puthelp "PRIVMSG $streamch :\002Current Song\002: $title"
 } else {
  puthelp "PRIVMSG $streamch :Couldn't receive any information, checking server status..."
 } 
}
Post Reply