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.

Help with timer script - chan var [RESOLVED]

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Help with timer script - chan var [RESOLVED]

Post by cache »

I am trying to make this run by a timer

Code: Select all

# Public/User Channel
set streamch "#public"

# Private/DJ Channel
set djch "#private"

set radiotime 5

package require http

set a "$botnick"
set a [string tolower "$nick"]

if {![info exists ald]} {
set ald 1
timer $radiotime get_shoutcast_song
}

proc get_shoutcast_song {} {
   global url streamch a radiotime
   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"
		timer $radiotime get_shoutcast_song
	} else {
		puthelp "PRIVMSG $chan :Couldn't receive any information, checking server status..."
		get_shoutcast_server $nick $uhost $hand $chan $arg
	}
   }
}
Error I get is:
[21:44] Tcl error in script for 'timer7716':
[21:44] can't read "chan": no such variable

Can someone please help me get the $chan variable added? I tried global chan with no luck.
Last edited by cache on Sat Jan 16, 2010 12:08 pm, edited 1 time in total.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

From where should we get the value for $chan?

If you're thinking of the "streamch" variable you set in the beginning of the script, why not just use that one?
NML_375
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

thank you for pointing that out to me :)
Post Reply