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.

What song playing

Old posts that have not been replied to for several years.
Locked
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

What song playing

Post by mrdr »

Hi, :)

I made this script:

Code: Select all

bind pub - !zip zip_procedura
set irc_kanalai ""


proc zip_procedura {nick host handle chan arg} {
global irc_kanalai
if {[catch {set sock_zipfm [socket www.zipfm.lt 80] } sockerror]} { 
putlog "news parsing error: $sockerror" 
return 0 } else { 
puts $sock_zipfm "GET /grojam.php HTTP/1.1" 
puts $sock_zipfm "User-Agent: eggdrop egghelp.nasa-team.net (c)" \
puts $sock_zipfm "Host: www.zipfm.lt" 
puts $sock_zipfm "Connection: close" 
puts $sock_zipfm "" 
flush $sock_zipfm 
set empt ""
set he "0"
while {[eof $sock_zipfm ] != 1} { 
set bl_rc [gets $sock_zipfm ]
if {$bl_rc == $empt} {
set he "1"
}
if {$he == "1"} {
set laikas [clock format [expr [clock seconds] + 60*60*24] -format " %H:%M:%S "]
while {[string match "<img src=img/icon_dabargrojame.gif width=12 height=11 border=0 align=absmiddle hspace=5>*" $bl_rc]} { 
regsub -all "<img src=img/icon_dabargrojame.gif width=12 height=11 border=0 align=absmiddle hspace=5>" $bl_rc "" served_rc_1
regsub -all "<img src=img/icon_dabargrojame.gif width=12 height=11 border=0 align=absmiddle hspace=5>" $bl_rc "" bl_rc
}
}
} 
close $sock_zipfm 
if {$irc_kanalai == "" } {
puthelp "NOTICE $nick :Zip FM dabar groja:\002 $served_rc_1 \002"
} else {
if {[string match -nocase *$chan* $irc_kanalai] != 0 } {
puthelp "PRIVMSG $chan :($laikas) Zip FM groja: $served_rc_1"
}
}
after 2000
}
putlog "Zip FM informacija gauta: $laikas"
}
But when I write in IRC command !zip bot in partyline says:

Code: Select all

TCL error [zip_procedura]: wrong # args: should be "puts ?-nonewline? ?channelId? string"
Help. :|
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Re: What song playing

Post by incith »

mrdr wrote:puts $sock_zipfm "User-Agent: eggdrop egghelp.nasa-team.net (c)" \
I think the trailing slash is screwing it up. :-)
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

Post by mrdr »

OK. Deleted that "\" and new error:

Code: Select all

TCL error [zip_procedura]: can't read "served_rc_1": no such variable
I know what it means. But server_rc_1 is here:

Code: Select all

regsub -all "<img src=img/icon_dabargrojame.gif width=12 height=11 border=0 align=absmiddle hspace=5>" $bl_rc "" served_rc_1

:|
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

it's there but it's not being set (because that [regsub] doesn't match), hence the error

DO NOT use raw sockets for quering webservers, use Tcl's built-in http package
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

Post by mrdr »

demond wrote:it's there but it's not being set (because that [regsub] doesn't match), hence the error

DO NOT use raw sockets for quering webservers, use Tcl's built-in http package
So... How can I fix that code? :oops:
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

obviously, by making sure [regsub] matches
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

Checking for variable existence is good, too.

Code: Select all

if {[info exists server_rc1]} { puts "$server_rc1" }
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

Post by mrdr »

Hrrr...
No luck with that script... :x
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
Locked