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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Fri Jan 13, 2006 1:57 pm
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
}
}
avilon
Halfop
Posts: 64 Joined: Tue Jul 13, 2004 6:58 am
Location: Germany
Post
by avilon » Fri Jan 13, 2006 3:11 pm
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sat Jan 14, 2006 7:07 am
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?
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Mon Jan 16, 2006 6:10 am
Anyone can help with timer?
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Mon Jan 16, 2006 6:27 am
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...
}
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Wed Jan 18, 2006 7:37 am
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
}
norway27
Voice
Posts: 7 Joined: Fri Jan 06, 2006 12:29 pm
Post
by norway27 » Thu Jan 19, 2006 12:25 pm
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
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Thu Jan 19, 2006 2:21 pm
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"
}
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Fri Jan 20, 2006 10:18 am
Any ideas why mroe than 1 regexp doesn`t work? i have no tcl errors.. bot do not send msg
norway27
Voice
Posts: 7 Joined: Fri Jan 06, 2006 12:29 pm
Post
by norway27 » Fri Jan 20, 2006 12:18 pm
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...
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Fri Jan 20, 2006 1:46 pm
Can you show me?
norway27
Voice
Posts: 7 Joined: Fri Jan 06, 2006 12:29 pm
Post
by norway27 » Sat Jan 21, 2006 6:20 pm
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!
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sat Jan 21, 2006 7:00 pm
Code: Select all
Tcl error [www:news4]: can't read "news": no such variable
norway27
Voice
Posts: 7 Joined: Fri Jan 06, 2006 12:29 pm
Post
by norway27 » Sat Jan 21, 2006 7:07 pm
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..
FcLan
Halfop
Posts: 64 Joined: Fri Sep 30, 2005 10:46 am
Location: Poland
Post
by FcLan » Sat Jan 21, 2006 7:16 pm
I need it for football results, so I need few veriables .. ;/