RSS Script and Hash tables - 05/01/11 11:27 AM
I have the following script:
The line that avoids dupe announces seems to be: - however I have a rss feed where the title of different entries is the same but the rss url is different so how would I make this line work with %RSS.Link instead of %RSS.title ?
I'm not very familiar with hash tables - I tried looking at the help file and doing /hsave to see what it looked like but got an error:
Code:
;RSS Routines by Ford_Lawnmower ;Just a few aliases I put together to bring RSS Pages to a channel ;Syntax is /RSS.Feed RSS-Name-One-Word http://RSS.Feed.Page.Address #ChannelNames,#Separated,#By,#commas,#Only Delay-in-Seconds ;Type /RSS.help for help. /RSS.Status to see all your Feeds. /RSS.kill to Stop a Feed in All channels. ;To Edit a feed, just re-type the original /RSS.Feed command with the changes and it will overwrite the old one. ;Questions, Comments. You can find me on WyldRyde #Script-Help, Mindforge #Technical, Abjects #Technical alias RSS.timeout { ;if (%RSS.chan != echo) { .msg %RSS.chan Connection was timed out... We could not find your site... :( } ;if (%RSS.chan == echo) { echo -a Connection was timed out... We could not find your site... :( } RSS.clear } alias RSS.clear { unset %RSS* ;unset all of the variables you use in the scrip here. Unless you need them to stay set sockclose RSS .timer-RSS off halt } alias RSS.help { echo -a $+ $chr(7) To start a RSS Feed type /RSS.Feed FeedName-Must-Be-One-String http://rss.address.here #channelnames,#separate,#with,#comma,#only SearchDelay echo -a $+ $chr(7) Ex. /RSS.Feed CNN-Top-Stories http://rss.cnn.com/rss/cnn_topstories.rss #USA,#Technical 1000 echo -a $+ $chr(7) **Note that The FeedName must be one string and the channels are separated by only a comma - No Space!. Also the delay defaults to 1200 and cannot be lower than 120 seconds. echo -a $+ $chr(7) Type /RSS.Status to see the status of all your feeds. /RSS.kill to end a feed. } alias RSS.kill { if (!$timer($1)) { echo -at That RSS feed does not exist to me ;/ Type RSS.Status to see a list of Feeds } if ($timer($1)) { .timer $+ $1 off | echo -at RSS feed $1 ended } } alias RSS.Status { var %timer.num = $timer(0) while (%timer.num) { if ($left($timer(%timer.num),3) == rss) { echo -at 07 $timer(%timer.num) = 04 $timer(%timer.num).com 06type09 /rss.kill $timer(%timer.num) 07to end this RSS Feed } dec %timer.num } } alias RSS.Feed { RSS $1 $2 $remove($3,$chr(32)) if ($4) && ($4 >= 120) { .timerRSS $+ $2 -o 1 $4 RSS.Feed $1 $2 $3 $4 } if (!$4) || ($4 < 120) { .timerRSS $+ $2 -o 1 1200 RSS.Feed $1 $2 $3 } } alias RSS { ;if (%RSS.inuse == 1) { echo -a RSS in use. To reset the script type /RSS.clear | return error1 | halt } set %RSS.inuse 1 set %RSS.nick $me set %RSS.chan ECHO set %RSS.chans $3 set %RSS.name $1 sockclose RSS set %RSSsite $gettok($remove($2,http://),1,47) set %RSSurl $remove($2,http://,%RSSsite) if (!$hget(%RSSsite)) { hmake %RSSsite 10 } set %RSS.Count 1 set %RSS.Max 4 sockopen RSS %RSSsite 80 .timer-RSS 1 20 RSS.timeout } on *:sockopen:RSS: { sockwrite -n $sockname GET %RSSurl HTTP/1.1 sockwrite -n $sockname Host: %RSSsite $+ $CRLF $+ $CRLF } ;this is triggered when above forces information into the buffer. on *:sockread:RSS: { if ($sockerr > 0) { .msg %RSS.chan There has been an error... >Sock Error< | RSS.clear } else { var %RSSvar | sockread %RSSvar ;the echo line below is for testing.. Don't forget to comment it out as soon as the script is working ;if (%RSSvar) echo -at %RSSvar if (<entry> isin %RSSvar) { set %RSS.Start on } if (</entry> isin %RSSvar) || (</item> isin %RSSvar) { set %RSS.Dup Off if ($hfind(%RSSsite,$right($remove(%RSS.title,$chr(32)),70))) { set %RSS.Dup ON } if (%RSS.Dup == Off) && (%RSS.Count <= %RSS.Max) { set %RSS.Output 1 while $gettok(%RSS.Chans,%RSS.Output,44) { if ($gettok(%RSS.Chans,%RSS.Output,44) ischan) { .msg $gettok(%RSS.Chans,%RSS.Output,44) 04 $+ %RSS.Name 07 $+ $remove(%RSS.Title,&) 06 $+ $replace($nospace(%RSS.Link),$chr(32),$chr(37) $+ 20) } inc %RSS.Output } inc %RSS.Count echo -a $replace(%RSS.Link,$chr(32),$chr(37) $+ 20) } hadd %RSSsite $right($remove(%RSS.title,$chr(32)),70) %RSS.Link $+ $chr(7) $+ %RSS.Title $+ $chr(7) $+ %RSS.Date $+ $chr(7) } if (<title> isin %RSSvar) { set %RSS.Title $gettok($replace(%RSSvar,<title>,$chr(7),</title>,$chr(7)),2,7) } if ($left(%RSSvar,7) == <title>) { set %RSS.Title $remove(%RSSvar,<title>,</title>) } if (<link href=" isin %RSSvar) { set %RSS.Link $nospace($remove(%RSSvar,<link href="," />)) } if (<link> isin %RSSvar) { set %RSS.Link $gettok($replace(%RSSvar,<link>,$chr(7),</link>,$chr(7)),2,7) } if ($left(%RSSvar,6) == <link>) { set %RSS.Link $remove(%RSSvar,<link>,</link>) } if (<updated> isin %RSSvar) { set %RSS.Date $gettok($replace(%RSSvar,<updated>,$chr(7),</updated>,$chr(7)),2,7) } if ($left(%RSSvar,9) == <updated>) { set %RSS.Date $remove(%RSSvar,<updated>,</updated>) } if (<pubdate> isin %RSSvar) { set %RSS.Date $gettok($replace(%RSSvar,<pubdate>,$chr(7),</pubdate>,$chr(7)),2,7) } if ($left(%RSSvar,9) == <pubdate>) { set %RSS.Date $remove(%RSSvar,<pubdate>,</pubdate>) } if (</feed> isin %RSSvar) || (</rss> isin %RSSvar) || (</channel> isin %RSSvar) { RSS.Clear } if (yes isin no) || (on isin off) { .msg %RSS.chan 4,1 $httpstrip(%RSSvar) sockread %RSSvar RSS.clear } } } alias -l flink { var %find.link = $1-,%found.link while ($left(%find.link,4) != http) && ($len(%find.link) > 8) { %found.link = $right(%find.link,$calc($len(%find.link) - 1)) } return %found.link } alias -l nospace { var %space.check = $1- while ($left(%space.check,1) == $chr(32)) { %space.check = $right(%space.check,$calc($len(%space.check) - 1)) } while ($right(%space.check,1) == $chr(32)) { %space.check = $left(%space.check,$calc($len(%space.check) -1)) } return %space.check } alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) return %x }
The line that avoids dupe announces seems to be:
Code:
if ($hfind(%RSSsite,$right($remove(%RSS.title,$chr(32)),70))) { set %RSS.Dup ON }
I'm not very familiar with hash tables - I tried looking at the help file and doing /hsave to see what it looked like but got an error:
Code:
/hsave %RSSsite rss.txt * /hsave: no such table '%RSSsite'