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.

check site

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

check site

Post by FcLan »

it is a news script, but I want to see latest news on channel only when site is updated.. can someone help?

Code: Select all

package require http

bind pub - !news www:news4

proc www:news4 {nick host handle chan text} {
   set token [::http::geturl http://www.eurosport.com/football/ -timeout 10000]
   set status [::http::status $token]
   if {$status!="ok"} {
      switch -exact -- [string tolower $status] {
         reset   { puthelp "PRIVMSG $chan :error: server connection was reset." }
         timeout { puthelp "PRIVMSG $chan :error: server timeout (10 seconds)"   }
         default { puthelp "PRIVMSG $chan :unknown server error occured"      }
      }
      ::http::cleanup $token; return
   }
   if {[::http::ncode $token]=="404"} {
      ::http::cleanup $token
      puthelp "PRIVMSG $chan :Sorry, error 404"; return
   }
   set data [::http::data $token]; ::http::cleanup $token
   set all [regexp -all -inline -nocase -- {class="storyshortmaintitle">(.*?)</a>} $data]
   set count 1
   foreach {tmp news} $all {
      if {$count=="2"} {return}
      puthelp "PRIVMSG $chan :www.eurosport.com - $news"
      incr count
   }
}
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

Use rssnews.tcl by demond and add this feed url: http://www.eurosport.com/football/rss.xml
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Yes, thanks, but I need to know, because all sites do not have a rss.. if it is too hard, where should I put the timer, to post latest news in every hour?
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Anyone can help with timer?
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You can use the time bind to call a proc every hour, something like:

Code: Select all

bind time - "00 *" foo

proc foo args {
 # call the news proc
 www:news4 arg1 arg2...
}
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Ok I tried to write, but it doesn`t work, i tried with normal site, with regexps which works on other scripts, here is a code with example site, where is mistake? Bot do not reply on trigger...

Code: Select all

package require http
bind pub - !test www:test
proc www:test {nick host handle chan text} {
                        set lastnews ""
                 set lastnews $match
                 set data [http::data http::geturl www.example.com]]
regexp {<td width="65%" class="medium">(.*?)</td><td align="right"} $data data match]
           if {$lastnews != ""} {
                                puthelp "PRIVMSG $chan :test - $match"
                                                 }
                                          set lastnews $macz
                                                                   }
n
norway27
Voice
Posts: 7
Joined: Fri Jan 06, 2006 12:29 pm

Re: check site

Post by norway27 »

FcLan wrote:it is a news script, but I want to see latest news on channel only when site is updated.. can someone help?

Code: Select all

package require http

bind pub - !news www:news4

proc www:news4 {nick host handle chan text} {
   set token [::http::geturl http://www.eurosport.com/football/ -timeout 10000]
   set status [::http::status $token]
   if {$status!="ok"} {
      switch -exact -- [string tolower $status] {
         reset   { puthelp "PRIVMSG $chan :error: server connection was reset." }
         timeout { puthelp "PRIVMSG $chan :error: server timeout (10 seconds)"   }
         default { puthelp "PRIVMSG $chan :unknown server error occured"      }
      }
      ::http::cleanup $token; return
   }
   if {[::http::ncode $token]=="404"} {
      ::http::cleanup $token
      puthelp "PRIVMSG $chan :Sorry, error 404"; return
   }
   set data [::http::data $token]; ::http::cleanup $token
   set all [regexp -all -inline -nocase -- {class="storyshortmaintitle">(.*?)</a>} $data]
   set count 1
   foreach {tmp news} $all {
      if {$count=="2"} {return}
      puthelp "PRIVMSG $chan :www.eurosport.com - $news"
      incr count
   }
}
It would be great if someone could show me how this script can read from 2 classes and post it in a chan..this script reads from one-> class="storyshortmaintitle"

Lets say the 2 classes are "storyshortmaintitle" and "story"

like this:

<user>!news
<bot> "storyshortmaintitle"
<bot> "story"

thx
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

I tried to make it also, but doesn`t work, don`t know why.. 0 errors in tcl..

Code: Select all

package require http

bind pub - !news www:news4

proc www:news4 {nick host handle chan text} {
   set token [::http::geturl http://www.eurosport.com/football/ -timeout 10000]
   set status [::http::status $token]
   if {$status!="ok"} {
      switch -exact -- [string tolower $status] {
         reset   { puthelp "PRIVMSG $chan :error: server connection was reset." }
         timeout { puthelp "PRIVMSG $chan :error: server timeout (10 seconds)"   }
         default { puthelp "PRIVMSG $chan :unknown server error occured"      }
      }
      ::http::cleanup $token; return
   }
   if {[::http::ncode $token]=="404"} {
      ::http::cleanup $token
      puthelp "PRIVMSG $chan :Sorry, error 404"; return
   }
   set data [::http::data $token]; ::http::cleanup $token
   set all [regexp -all -inline -nocase -- {class="storyshortmaintitle">(.*?)</a>} $data]
   set count 1
   foreach {tmp news} $all {
      if {$count=="2"} {return}
}
set all2 [regexp -all -inline -nocase -- {class="(.*?)</a>} $data]
      
set count 1
   foreach {tmp news2} $all2 {
      if {$count=="2"} {return}
      incr count
   }
 puthelp "PRIVMSG $chan :www.eurosport.com - $news - $news2"
}
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Any ideas why mroe than 1 regexp doesn`t work? i have no tcl errors.. bot do not send msg
n
norway27
Voice
Posts: 7
Joined: Fri Jan 06, 2006 12:29 pm

Post by norway27 »

FcLan wrote:Any ideas why mroe than 1 regexp doesn`t work? i have no tcl errors.. bot do not send msg
I got it to work a little bit if I typed in the name of the same class in both places...
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Can you show me?
n
norway27
Voice
Posts: 7
Joined: Fri Jan 06, 2006 12:29 pm

Post by norway27 »

Something like this:

Code: Select all

package require http

bind pub - !news www:news4

proc www:news4 {nick host handle chan text} {
   set token [::http::geturl http://www.webpage.com -timeout 10000]
   set status [::http::status $token]
   if {$status!="ok"} {
      switch -exact -- [string tolower $status] {
         reset   { puthelp "PRIVMSG $chan :error: server connection was reset." }
         timeout { puthelp "PRIVMSG $chan :error: server timeout (10 seconds)"   }
         default { puthelp "PRIVMSG $chan :unknown server error occured"      }
      }
      ::http::cleanup $token; return
   }
   if {[::http::ncode $token]=="404"} {
      ::http::cleanup $token
      puthelp "PRIVMSG $chan :Sorry, error 404"; return
   }
   set data [::http::data $token]; ::http::cleanup $token
   set all [regexp -all -inline -nocase -- {class="class_story">(.*?)</a>} $data]
   set count 1
   foreach {tmp news} $all {
      if {$count=="2"} {return}
}
set all2 [regexp -all -inline -nocase -- {class="class_story"(.*?)</a>} $data]
      
set count 1
   foreach {tmp news2} $all2 {
      if {$count=="2"} {return}
      incr count
   }
 puthelp "PRIVMSG $chan :www.webpage.com - $news"
 puthelp "PRIVMSG $chan :www.webpage.com - $news2"
}
It was messy..got alot of html code too with it...but the bot did respond with
line 1: topic
Line 2: topic & story

I hope someone can try to fix this code because I have no idea what to do!
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Code: Select all

Tcl error [www:news4]: can't read "news": no such variable
n
norway27
Voice
Posts: 7
Joined: Fri Jan 06, 2006 12:29 pm

Post by norway27 »

FcLan wrote:

Code: Select all

Tcl error [www:news4]: can't read "news": no such variable
Yes I got that too sometimes..I had to search through the page for another class and then change the name of the class in the script until I got it right..
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

I need it for football results, so I need few veriables .. ;/
Post Reply