egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

I wrote my own shoutcast script but need help plz :o

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
NTHosts
Op


Joined: 10 Oct 2005
Posts: 100
Location: UK

PostPosted: Sat Mar 04, 2006 11:35 am    Post subject: I wrote my own shoutcast script but need help plz :o Reply with quote

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 ? Razz

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 ? Smile
_________________
www.NT-Hosts.Net - More than just a host
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Mar 04, 2006 1:03 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
NTHosts
Op


Joined: 10 Oct 2005
Posts: 100
Location: UK

PostPosted: Sat Mar 04, 2006 1:09 pm    Post subject: hehe Reply with quote

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 Smile
_________________
www.NT-Hosts.Net - More than just a host
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Mar 04, 2006 2:11 pm    Post subject: Reply with quote


  • '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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber