# slsk.tcl by 5th Raider
# Requires egghttp.tcl
# Config
set url "http://www.remmelt.com/slskboard/status.php"
set pubtrigger "!soulseek"
# End of config
if {![info exists egghttp(version)]} {
putlog "egghttp.tcl was NOT successfully loaded."
putlog "slsk.tcl has not been loaded as a result."
} else {
proc your_callbackproc {sock} {
global url served
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
regsub -all "\n" $body "" body
regsub -all -nocase {<br>} $body "<br>\n" body
regexp {the server (.*)<br>} $body {} served
putlog "Soulseek server $served - $url."
}
bind pub - $pubtrigger our:pubtrigger
proc our:pubtrigger {nick uhost hand chan text} {
global url served
set sock [egghttp:geturl $url your_callbackproc]
putserv "NOTICE $nick : Soulseek server $served - $url"
return 1
}
putlog "slsk.tcl by 5th Raider - Loaded."
}
# slsk.tcl by 5th Raider
# Requires egghttp.tcl
# Config
set url "http://www.remmelt.com/slskboard/status.php"
set pubtrigger "!soulseek"
# End of config
if {![info exists egghttp(version)]} {
putlog "egghttp.tcl was NOT successfully loaded."
putlog "slsk.tcl has not been loaded as a result."
} else {
proc your_callbackproc {sock} {
global url served
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
regsub -all "\n" $body "" body
regsub -all -nocase {<br>} $body "<br>\n" body
set served ""
regexp {the server (.*)<br>} $body {} served
putlog "Soulseek server $served - $url."
}
bind pub - $pubtrigger our:pubtrigger
proc our:pubtrigger {nick uhost hand chan text} {
global url served
set sock [egghttp:geturl $url your_callbackproc]
putserv "NOTICE $nick : Soulseek server $served - $url"
return 1
}
putlog "slsk.tcl by 5th Raider - Loaded."
}
Variable $served does not exists in first launch. Just set her before regexp.
Thunderdome wrote:This does not work... give exactly the same error...
You have to comprehend how variables work. You get this error because you have not defined set served "whatever this does". I suggest you read this Tcl Variables Tutorial as well as Assigning values to variables to better understand what you are doing incorrectly
set served "regexp {the server (.*)<br>} $body {} served "
should this be it?
I don't get it.. if the variable was not defined, it should never work, and not only not work at the first time... :\
Served returns the "value" between "the server" and "<br>" in that webpage.
that is what this means:
so with this, served should be defined...
but does not get it at first.... seems like it has to be run once to have something in "memory" to give the second time...
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
In fact it does... but it shows only the text without saying the part I want from the site... that is, it does not say if the server is up or down.... :\
and I can't understand why...
Thunderdome wrote:In fact it does... but it shows only the text without saying the part I want from the site... that is, it does not say if the server is up or down.... :\
and I can't understand why...
read a good TCL book, or learn online using tons of useful resources; study other people's code, and try to code stuff yourself, starting with basic things
then you won't be that puzzled and unable to grasp simple notions like global variables
I tried to make that myself... and I have read about variables in online tutorials... but I don't get what is wrong...
I just need help to fix it... can you just write was is wrong?
Thanks
regexp {the server (.*)<br>} $body {} served
putlog "Soulseek server $served - $url."
here, if [regexp] doesn't find a match, served won't be set, hence the "No such variable" error on the next line; in TCL, unlike C, every variable must be initialized (with [set] or implicitly by some other commands) before being used
that [regexp], judging by its arguments, needs to be changed to [regsub]