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.

Small sock problem

Help for those learning Tcl or writing their own scripts.
Post Reply
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Small sock problem

Post by FcLan »

I`ve a livescore script for my eggdrop. It works, but the problem is it gives results from down from bottom i want to see results from top and not only one, for example frist 5 please help me, thx.

Code: Select all

set url "www.pilkanozna.pl"

 proc get_news {nick uhost handle channel text} {
 global url
 set sock [socket $url 80]
 fconfigure $sock -buffering line -buffersize 1000
 puts $sock "GET /pn.php?dzial=online HTTP/1.0"
 puts $sock "Host: www.pilkanozna.pl"
 puts $sock ""
 puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; WindowsNT 5.0)"
 flush $sock

 while {![eof $sock]} {
 gets $sock body
 regexp -all {<td align=right>(.*?)</td>} $body _ team1
 regexp -all {<td align=center>(.*?)</td>} $body _ result
 regexp -all {<td align=left>(.*?)</td>} $body _ team2
}

if {[eof $sock]} { close $sock }

 regsub -all {(<.+?>)} $team1"" team1
 regsub -all {(<.+?>)} $result"" result
 regsub -all {(<.+?>)} $team2"" team2

 puthelp "PRIVMSG $channel :[lindex $team1][lindex $result][lindex $team2]"

}

bind pub - !score get_news
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

don't use raw sockets for HTTP, use the http package and its [geturl] command
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Hmm, I understand only a sock.. really can`t change it?
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Can u show me example script "http package and its [geturl] command" ?
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

Post Reply