This is the new home of the egghelp.org community forum. this announcement post . Click the X in the top right-corner of this box to dismiss this message. 
Help for those learning Tcl or writing their own scripts.
			
		
				
			
				
								NTHosts 							 
						Op 			
		Posts:  100 Joined:  Mon Oct 10, 2005 9:57 pmLocation:  UK
				Contact: 
				
			 
				
		 
		
						
					
													
							
						
									
						Post 
					 
								by NTHosts  Sat Mar 04, 2006 11:35 am 
			
			
			
			
			
			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: Select all 
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 ? 
 
		 
				
		
		 
	 
				
		
				
			
				
								demond 							 
						Revered One 			
		Posts:  3073 Joined:  Sat Jun 12, 2004 9:58 amLocation:  San Francisco, CA
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by demond  Sat Mar 04, 2006 1:03 pm 
			
			
			
			
			
			1. post your script with proper indentation
			
			
									
						
							connection, sharing, dcc problems? click 
<here> 
before asking for scripting help, read 
<this> 
use 
 
		 
				
		
		 
	 
				
		
				
			
				
								NTHosts 							 
						Op 			
		Posts:  100 Joined:  Mon Oct 10, 2005 9:57 pmLocation:  UK
				Contact: 
				
			 
				
		 
		
						
					
													
							
						
									
						Post 
					 
								by NTHosts  Sat Mar 04, 2006 1:09 pm 
			
			
			
			
			
			demond wrote: 1. post your script with proper indentation
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: Select all 
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 
 
		 
				
		
		 
	 
				
		
				
			
				
								demond 							 
						Revered One 			
		Posts:  3073 Joined:  Sat Jun 12, 2004 9:58 amLocation:  San Francisco, CA
				Contact: 
				
			 
				
		 
		
						
					
						 
													
							
						
									
						Post 
					 
								by demond  Sat Mar 04, 2006 2:11 pm 
			
			
			
			
			
			
'proper indentation' means writing/posting like this:
and not  like this:
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