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.

Egghttp 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

Egghttp problem

Post by FcLan »

Welcome after break :D I have some problem with my http script.. I would like that bot don`t reply this same news, text from any site, and i want to read more than only 1 st news, also if it is possible i would like to add timer to this script like in mirc for ex /timer 0 300 /anyalias, but when i trying with this script bot reply the same text.. and read only frist news

Code: Select all

package require http
bind pub - !news www:news
proc www:news {nick host handle chan text} {
        set token [::http::geturl http://anysite.com -timeout 10000]
        set status [::http::status $token]
        ::http::cleanup $token;

                 set data [http::data [http::geturl http://anysite.com]]
                 regexp {<html>(.*?)<html>} $data data something
     set news "$something"
      set news.old "$news"

        set count 3
                   if {$count=="5"} {return}
        
             if {$news != "news.old"} {

                   puthelp "PRIVMSG $chan :$news"

         incr count
 }
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you are not using egghttp anything... you use http with eggdrop, not egghttp :D.

You can 'loop' procs by using timer or utimer at their end to call themselves (read tcl-commands.doc or search this board for references).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

ok, I`ll look, but why bot reply the same text, what`s wrong?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

It should only change, when the page actually changes. I can see only these strange things:

Code: Select all

        set count 3
                   if {$count=="5"} {return} 
Will be always false... you could also write 'if 0 {return}' :D

Code: Select all

     set news "$something" 
redudant... just use news from beginning or continue with something. btw you dont need these "" around variables as long you don't operate with strings that might cause to false list interpretations (or simply for code readablility/clearity)

Code: Select all

      set news.old "$news" 
...
             if {$news != "news.old"} { 
Look like you wanted to write '$news != $news.old' instead :) (putting around "" at this one, will even cause the unexpected behavior that it compares '$news' with '$news' + '.old' :D)

Code: Select all

         incr count
 }
since count is no global var (and should be avoided to be used by that common name), it will only make the proc return the value '4' and value gets lost..

maybe some of these hints help you.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

sorry, it does not help me :(
Post Reply