| View previous topic :: View next topic |
| Author |
Message |
NTHosts Op
Joined: 10 Oct 2005 Posts: 100 Location: UK
|
Posted: Sat Mar 04, 2006 11:35 am Post subject: I wrote my own shoutcast script but need help plz :o |
|
|
Ok heres the silly attempt at me writing tcl, well, i just poked around other ppls scripts and took bits out, but it all counts right ?
| Code: | set topictrigger "!topic"
set streamip "stream.lynxfm.info"
set streamport "9000"
set streampass "zigzag"
set radiochans "#LynxFM"
bind pub - $topictrigger pub_topic
bind msg - $topictrigger msg_topic
proc topic { target } {
global streamip streamport streampass
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 topic "topic: [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]"
}}
putquick "PRIVMSG $target :$topic"
proc msg_topic { nick uhost hand arg } { topic $chan}
proc pub_topic { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans][string tolower $chan]] != -1) || ($radiochans == "")} { topic $chan }}}} |
When i try the !topic.. i get this error..
[10:28] Tcl error [pub_topic]: invalid command name "pub_topic"
im pulling my hair out with this 1, i also dont really want it to msg then channel, but rather to change its topic.
Any ideas please ?  _________________ www.NT-Hosts.Net - More than just a host |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Mar 04, 2006 1:03 pm Post subject: |
|
|
1. post your script with proper indentation
2. don't use raw socket, use http package
3. your error is likely due to unbalanced braces _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
NTHosts Op
Joined: 10 Oct 2005 Posts: 100 Location: UK
|
Posted: Sat Mar 04, 2006 1:09 pm Post subject: hehe |
|
|
| demond wrote: | 1. post your script with proper indentation
2. don't use raw socket, use http package
3. your error is likely due to unbalanced braces |
Proper Indentation ?
http package ?
unbalanced braces ??
omg sorry i have no idea what any of that means, like i said i just chopped a few other scripts and put them together.
I did do a little rewrite, now i dont get errors it just dont do anything.. heres the script..
| Code: |
set topictrigger "!topic"
set streamip "stream.lynxfm.info"
set streamport "9000"
set streampass "password"
set radiochans "#LynxFM"
bind pub - $topictrigger pub_topic
bind msg - $topictrigger msg_topic
proc topic { target } {
global streamip streamport streampass
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 topic [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]
}}
putquick "PRIVMSG $target : $topic "
proc msg_topic { nick uhost hand arg } { topic $chan}
proc pub_topic { nick uhost hand chan arg } { global radiochans; if {([lsearch -exact [string tolower $radiochans][string tolower $chan]] != -1) || ($radiochans == "")} { topic $chan }}}} |
Thanks for any help you can give  _________________ www.NT-Hosts.Net - More than just a host |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Mar 04, 2006 2:11 pm Post subject: |
|
|
- 'proper indentation' means writing/posting like this:
| Code: |
if {$flag} {
set foo $bar
}
|
and not like this:
| Code: |
if {$flag} {
set foo $bar
}
|
the former is easier to read, the latter is harder
go to http package manpage ('manpage' means manual page) and learn about it
'unbalanced braces' means you have different number of opening { and closing } characters; sometimes Tcl reports that directly, sometimes not; and if not, the error message is misleading
use .set errorInfo to obtain backtrace on the error
_________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|