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 simple

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

help simple

Post by FcLan »

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
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

ever heard of Tcl's http package?
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 »

Yes, but i can`t understand it.. its too much easier on socks
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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

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 »

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.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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

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 »

Oh, sorry i forgot, btw. I know about it :D
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

...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

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 »

Bot do not sends any msg
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Try

Code: Select all

.set errorInfo
.. 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
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

I can`t understand:

Code: Select all

set source [string map -nocase {"|"} $source]
foreach line [split $source |] {
if {[regexp {(.*?)} $line tmp lines ]} { 
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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

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 »

I don`t understand.. I need a simple example script and I will understand it
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

yes, but where is regexps, and msg to channel??
Post Reply