egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help simple
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Fri Dec 16, 2005 8:54 am    Post subject: help simple Reply with quote

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:

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
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Dec 16, 2005 11:28 pm    Post subject: Reply with quote

ever heard of Tcl's http package?
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sat Dec 17, 2005 12:30 pm    Post subject: Reply with quote

Yes, but i can`t understand it.. its too much easier on socks
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Dec 17, 2005 1:07 pm    Post subject: Reply with quote

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] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sat Dec 17, 2005 2:24 pm    Post subject: Reply with quote

Ok I`ve read something about it and imo all is ok: Tell me why this one dont works....

Code:
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
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Dec 17, 2005 3:58 pm    Post subject: Reply with quote

learn how to post first - meaning posting code within [code] tags and explaining in details what the problem is, providing detailed log and error traceback; then I might tell you
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sat Dec 17, 2005 4:45 pm    Post subject: Reply with quote

Oh, sorry i forgot, btw. I know about it Very Happy
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Dec 17, 2005 9:21 pm    Post subject: Reply with quote

Quote:

...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] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sun Dec 18, 2005 6:58 am    Post subject: Reply with quote

Bot do not sends any msg
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sun Dec 18, 2005 7:45 am    Post subject: Reply with quote

Try
Code:
.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
Back to top
View user's profile Send private message Visit poster's website
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sun Dec 18, 2005 8:16 am    Post subject: Reply with quote

I can`t understand:

Code:
set source [string map -nocase {"|"} $source]
foreach line [split $source |] {
if {[regexp {(.*?)} $line tmp lines ]} {
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sun Dec 18, 2005 12:48 pm    Post subject: Reply with quote

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:

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] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Wed Dec 21, 2005 9:46 am    Post subject: Reply with quote

I don`t understand.. I need a simple example script and I will understand it
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Dec 21, 2005 5:05 pm    Post subject: Reply with quote

demond wrote:

start with the simplest thing - fetch google's homepage:
Code:

package require http
set t [::http::geturl http://www.google.com]
::http::data $t
::http::cleanup $t


isn't that a simple script? Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Thu Dec 22, 2005 5:53 am    Post subject: Reply with quote

yes, but where is regexps, and msg to channel??
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber