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.
Old posts that have not been replied to for several years.
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Sat Jun 26, 2004 10:52 pm
Hi, I made this script to retrieve website data at timed intervals, but I'm trying to make it so it will not send anything to the channel if the var $rtr hasn't changed since the last check...would appreciate any help - thanks!
Code: Select all
proc pub:rtr { nick uhost handle channel arg } {
set sock [egghttp:geturl http://www.myurl.com/ getrtr]
return 1
}
proc getrtr {sock} {
global rtrurl
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
foreach line [split $body \n] {
if {[string match "*52_*" $line]} {
set rtr [gettok $line 2 62]
set rtr [gettok $rtr 0 60]
set rtrurl [gettok $line 5 34]
putserv "PRIVMSG #channel :/0034,4 /0031,15 $rtr /00314,14 /003"
}
}
}
strikelight
Owner
Posts: 708 Joined: Mon Oct 07, 2002 10:39 am
Contact:
Post
by strikelight » Sun Jun 27, 2004 2:01 am
NewzBoy wrote: Hi, I made this script to retrieve website data at timed intervals, but I'm trying to make it so it will not send anything to the channel if the var $rtr hasn't changed since the last check...would appreciate any help - thanks!
Code: Select all
proc pub:rtr { nick uhost handle channel arg } {
set sock [egghttp:geturl http://www.myurl.com/ getrtr]
return 1
}
proc getrtr {sock} {
global rtrurl
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
foreach line [split $body \n] {
if {[string match "*52_*" $line]} {
set rtr [gettok $line 2 62]
set rtr [gettok $rtr 0 60]
set rtrurl [gettok $line 5 34]
putserv "PRIVMSG #channel :/0034,4 /0031,15 $rtr /00314,14 /003"
}
}
}
You will need to store a copy into a global variable and check against it then...
Code: Select all
proc getrtr {sock} {
global rtrurl rtrold
set headers [egghttp:headers $sock]
set body [egghttp:data $sock]
egghttp:cleanup $sock
foreach line [split $body \n] {
if {[string match "*52_*" $line]} {
set rtr [gettok $line 2 62]
set rtr [gettok $rtr 0 60]
set rtrurl [gettok $line 5 34]
if {![info exists rtrold] || ($rtr != $rtrold)} {
putserv "PRIVMSG #channel :/0034,4 /0031,15 $rtr /00314,14 /003"
} else {
set rtrold $rtr
}
}
}
}
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Sun Jun 27, 2004 2:22 am
thanks strikelight - since I posted that, I added a couple of else/elseif's to deal with some content in the $var :
if {[string is upper $rtr]} {
putserv "PRIVMSG #channel :4,4 0,4 [gettime +0]ET $rtr "
} elseif {[string match *-* $rtr]} {
putserv "PRIVMSG #Newsroom2 :7,7 1,15 [gettime +0]ET $rtr "
} else {
putserv "PRIVMSG #Newsroom2 :4,4 1,15 [gettime +0]ET $rtr "
will that mess up the:
} else {
set rtrold $rtr
? thanks again
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Sun Jun 27, 2004 2:36 am
actually, I think I answered my own question there - just added the setting of the old var to the new one after each of the else/if's.
thanks again for the help, and will see how it goes!
strikelight
Owner
Posts: 708 Joined: Mon Oct 07, 2002 10:39 am
Contact:
Post
by strikelight » Sun Jun 27, 2004 3:46 am
Actually, dunno what I was thinking when I posted that...
But...
Change the:
To just:
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Sun Jun 27, 2004 3:50 am
one more question if I could - with regards to 'string is upper', I've got a different style to print to the channel if the text is upper, however I've found if there are numerals or other symbols involved, it dosn't seem to work as the upper line, and sends it in the 'else' e.g.:
POWERFUL EXPLOSION HEARD IN CENTRAL BAGHDAD - REUTERS WITNESSES
did not get recognised as an 'is upper'.
any ideas on how it could do so if all the letters are upper no matter if there are other symbols in the line?
thanks.
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Sun Jun 27, 2004 3:52 am
strikelight wrote: Actually, dunno what I was thinking when I posted that...
But...
Change the:
To just:
cool got that one thanks
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Mon Jun 28, 2004 12:50 am
NewzBoy wrote: any ideas on how it could do so if all the letters are upper no matter if there are other symbols in the line?
Code: Select all
if {![string match {*[a-z]*} $str]} {
# $str does not contain any lowercase letters
}
Have you ever read "The Manual"?
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Mon Jun 28, 2004 8:38 am
thanks user - it's working great!
one more thing about strings (slowly getting through the list!)
sometimes when retrieving text from a website, it puts extra characters with certain characters, like this for '&':
S&P Affirms ANZ National Bank Ratings
it puts 'amp;' with the '&'
so what I'm wondering is if I can specify to remove the amp; part, if it appears in a string, like $remove(%var,amp;) would do in mIRC...
thanks again.
greenbear
Owner
Posts: 733 Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway
Post
by greenbear » Mon Jun 28, 2004 11:33 am
Something like this should work
Code: Select all
set str [string map {"&" "\&"} $str]
NewzUK
Master
Posts: 200 Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:
Post
by NewzUK » Mon Jun 28, 2004 9:16 pm
that's working - thanks alot =)