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 

check site
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Fri Jan 13, 2006 1:57 pm    Post subject: check site Reply with quote

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

Code:
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
   }
}
Back to top
View user's profile Send private message
avilon
Halfop


Joined: 13 Jul 2004
Posts: 64
Location: Germany

PostPosted: Fri Jan 13, 2006 3:11 pm    Post subject: Reply with quote

Use rssnews.tcl by demond and add this feed url: http://www.eurosport.com/football/rss.xml
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sat Jan 14, 2006 7:07 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Mon Jan 16, 2006 6:10 am    Post subject: Reply with quote

Anyone can help with timer?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jan 16, 2006 6:27 am    Post subject: Reply with quote

You can use the time bind to call a proc every hour, something like:
Code:
bind time - "00 *" foo

proc foo args {
 # call the news proc
 www:news4 arg1 arg2...
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
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 Jan 18, 2006 7:37 am    Post subject: Reply with quote

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:
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
                                                                   }
Back to top
View user's profile Send private message
norway27
Voice


Joined: 06 Jan 2006
Posts: 7

PostPosted: Thu Jan 19, 2006 12:25 pm    Post subject: Re: check site Reply with quote

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:
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
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Thu Jan 19, 2006 2:21 pm    Post subject: Reply with quote

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

Code:
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"
}
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Fri Jan 20, 2006 10:18 am    Post subject: Reply with quote

Any ideas why mroe than 1 regexp doesn`t work? i have no tcl errors.. bot do not send msg
Back to top
View user's profile Send private message
norway27
Voice


Joined: 06 Jan 2006
Posts: 7

PostPosted: Fri Jan 20, 2006 12:18 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Fri Jan 20, 2006 1:46 pm    Post subject: Reply with quote

Can you show me?
Back to top
View user's profile Send private message
norway27
Voice


Joined: 06 Jan 2006
Posts: 7

PostPosted: Sat Jan 21, 2006 6:20 pm    Post subject: Reply with quote

Something like this:


Code:
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!
Back to top
View user's profile Send private message
FcLan
Halfop


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sat Jan 21, 2006 7:00 pm    Post subject: Reply with quote

Code:
Tcl error [www:news4]: can't read "news": no such variable
Back to top
View user's profile Send private message
norway27
Voice


Joined: 06 Jan 2006
Posts: 7

PostPosted: Sat Jan 21, 2006 7:07 pm    Post subject: Reply with quote

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


Joined: 30 Sep 2005
Posts: 64
Location: Poland

PostPosted: Sat Jan 21, 2006 7:16 pm    Post subject: Reply with quote

I need it for football results, so I need few veriables .. ;/
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 -> Script Requests 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