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.
Help for those learning Tcl or writing their own scripts.
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Fri Dec 16, 2005 8:54 am
Hi i wrote a script which check my postion in some ranking imy id is 582 so url is: puts $sock "GET /index.php?site=online_segastatpers&uid=582
but i want if someone type !my_id example: !566 it will change url to 566 id:
puts $sock "GET /index.php?site=online_segastatpers&uid=566 and tell a place for this id it is a script:
Code: Select all
set url "www.sensiblesoccer.de"
proc get_projects {nick uhost handle channel text} {
global url
set sock [socket $url 80]
fconfigure $sock -buffering line -buffersize 1000
puts $sock "GET /index.php?site=online_segastatpers&uid=582 HTTP/1.0"
puts $sock "Host: www.sensiblesoccer.de"
puts $sock ""
puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
flush $sock
while {![eof $sock]} {
gets $sock body
regexp -all {<td width="65%" class="medium">(.*?)</td><td} $body _ served
}
if {[eof $sock]} { close $sock }
regsub -all {(<.+?>)} $served "" served
puthelp "PRIVMSG $channel :[lindex $served]"
}
bind pub - !projects get_projects
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Fri Dec 16, 2005 11:28 pm
ever heard of Tcl's http package?
connection, sharing, dcc problems? click
<here>
before asking for scripting help, read
<this>
use
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sat Dec 17, 2005 12:30 pm
Yes, but i can`t understand it.. its too much easier on socks
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Sat Dec 17, 2005 1:07 pm
I'd bet you haven't bothered to even read Tcl doc page about http package, let alone judging it against raw sockets
and if you really have read it and couldn't understand it - while you understand sockets - there is something wrong with you, since it's really simpler than sockets - to understand and to use
connection, sharing, dcc problems? click
<here>
before asking for scripting help, read
<this>
use
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sat Dec 17, 2005 2:24 pm
Ok I`ve read something about it and imo all is ok: Tell me why this one dont works....
Code: Select all
bind pub - !news newscheck
proc newscheck {nick host hand chan text} {
set url "www.sensiblesoccer.de/index.php?lng=en"
set counter 0
set http(-useragent) {Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)}
set limit "4"
catch { set connection [http::geturl $url -timeout 3000] } error
if {[string match -nocase "*::http::*" $error]} {
set source [http::data $connection];http::cleanup $connection
set source [string map -nocase {"|"} $source]
foreach line [split $source |] {
if {[regexp {(.*?)} $line tmp lines ]} {
regexp {<td class="medium"><b class="marker">(.*?)</font></td>} $lines tmp titel
putserv "PRIVMSG $chan :$titel"
incr counter
}
if {$counter == $limit} {unset counter;return 0}
}
}
}
Last edited by
FcLan on Sat Dec 17, 2005 4:44 pm, edited 1 time in total.
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Sat Dec 17, 2005 3:58 pm
learn how to post first - meaning posting code within
Code: Select all
tags and explaining in details what the problem is, providing detailed log and error traceback; then I [i]might[/i] tell you
connection, sharing, dcc problems? click
<here>
before asking for scripting help, read
<this>
use
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sat Dec 17, 2005 4:45 pm
Oh, sorry i forgot, btw. I know about it
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Sat Dec 17, 2005 9:21 pm
...AND explaining in details what the problem is, providing detailed log and error traceback
connection, sharing, dcc problems? click
<here>
before asking for scripting help, read
<this>
use
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sun Dec 18, 2005 6:58 am
Bot do not sends any msg
Alchera
Revered One
Posts: 3344 Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:
Post
by Alchera » Sun Dec 18, 2005 7:45 am
Try
.. and paste what you get; also read what is in your bots own log and paste any relevant info.
Add [SOLVED] to the thread title if your issue has been.
Search |
FAQ |
RTM
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sun Dec 18, 2005 8:16 am
I can`t understand:
Code: Select all
set source [string map -nocase {"|"} $source]
foreach line [split $source |] {
if {[regexp {(.*?)} $line tmp lines ]} {
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Sun Dec 18, 2005 12:48 pm
you can't understand what you wrote yourself? not that's weird...
I already told you (or was it another guy...) to skip async processing for now and try just basic blocking mode - that is, remove
-command switch from [geturl]
start with the simplest thing - fetch google's homepage:
Code: Select all
package require http
set t [::http::geturl http://www.google.com]
::http::data $t
::http::cleanup $t
examine the structure of the page you need to parse by using appropriate tool (for example, DOM Inspector of Mozilla/Firefox); once you have a clear idea what that structure is, go for the parsing - 1. learn regexps and 2. learn from decent HTML parsing scripts, for example incith's or
rssnews
connection, sharing, dcc problems? click
<here>
before asking for scripting help, read
<this>
use
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Wed Dec 21, 2005 9:46 am
I don`t understand.. I need a simple example script and I will understand it
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Wed Dec 21, 2005 5:05 pm
demond wrote:
start with the simplest thing - fetch google's homepage:
Code: Select all
package require http
set t [::http::geturl http://www.google.com]
::http::data $t
::http::cleanup $t
isn't that a simple script?
Once the game is over, the king and the pawn go back in the same box.
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Thu Dec 22, 2005 5:53 am
yes, but where is regexps, and msg to channel??