alias RSS1.0 {
dialog -m RSSFeed1 RSSFeed1
}
dialog RSSFeed1 {
title "RSS Feed 1.0"
size -1 -1 104 136
option dbu
list 1, 8 16 90 82
button "Add", 2, 8 104 29 12
button "Delete", 3, 40 104 29 12
button "Edit", 4, 72 104 29 12
button "Close", 5, 8 120 93 12, ok cancel
text "Click Add or Click a feed to Edit/Del ", 6, 8 8 89 8, center
}
dialog RSSFeed2 {
title "RSS Feed 1.0 Add/Edit"
size -1 -1 104 104
option dbu
edit "", 1, 8 16 42 10, autohs
text "RSS Name", 2, 8 8 41 8, center
edit "", 3, 8 40 90 10, autohs
edit "", 4, 56 16 42 10, autohs
text "Delay in Seconds", 5, 56 8 41 8, center
text "RSS Feed Link - ie https://Rss.Bla", 6, 8 32 89 8, center
edit "", 7, 8 64 90 10, autohs
text "Chans for Feed Separate w/Space", 8, 8 56 89 8
button "Accept", 9, 8 80 37 12, ok
button "Cancel", 10, 60 80 37 12, cancel
}
On *:dialog:RSSFeed1:init:*: {
didtok RSSFeed1 1 32 %Global.Feed.List
}
On *:dialog:RSSFeed2:init:*: {
did -a RSSFeed2 1 %Feed.Name
did -a RSSFeed2 3 %Feed.Link
did -a RSSFeed2 4 %Feed.Delay
did -a RSSFeed2 7 %Feed.Chans
}
On *:dialog:RSSFeed1:Sclick:*: {
if ($did == 2) {
dialog -x RSSFeed1
dialog -m RSSFeed2 RSSFeed2
}
if ($did == 3) {
if ($did(1).sel) {
.timerRSS [ $+ [ $gettok($hget(rssfeed,$did(1).seltext),1,32) ] ] off
hdel RSSFeed $did(1).seltext
did -d RSSFeed1 1 $did(1).sel
set %Global.Feed.List $didtok(RSSFeed1,1,32)
else { return }
}
}
if ($did == 4) {
if ($did(1).sel) {
set %Feed.Name $did(1).seltext
set %Feed.Link $gettok($hget(rssfeed,$did(1).seltext),1,32)
set %Feed.Chans $gettok($hget(rssfeed,$did(1).seltext),2,32)
set %Feed.Delay $gettok($hget(rssfeed,$did(1).seltext),3,32)
dialog -x RSSFeed1
dialog -m RSSFeed2 RSSFeed2
}
else { halt }
}
}
On *:dialog:RSSFeed2:Sclick:*: {
if ($did == 9) {
if ($hget(rssfeed,%Feed.Name)) {
.timerRSS [ $+ [ $gettok($hget(rssfeed,%Feed.Name),1,32) ] ] off
hdel RSSFeed %Feed.Name
set %Global.Feed.List $remove(%Global.Feed.List,$replace(%Feed.Name,$chr(32),-))
}
if (%Feed.Name.Temp) {
if ($hget(rssfeed,$replace(%Feed.Name.Temp,$chr(32),-))) {
.timerRSS [ $+ [ $gettok($hget(rssfeed,%Feed.Name.Temp),1,32) ] ] off
hdel RSSFeed %Feed.Name.Temp
set %Global.Feed.List $remove(%Global.Feed.List,$replace(%Feed.Name.Temp,$chr(32),-))
}
set %Feed.Name %Feed.Name.Temp
}
if (%Feed.Link.Temp) { set %Feed.Link %Feed.Link.Temp }
if (%Feed.Delay.Temp) { set %Feed.Delay %Feed.Delay.Temp }
if (%Feed.Chans.Temp) { set %Feed.Chans %Feed.Chans.Temp }
if (!%Feed.Name) || (!%Feed.Link) || (!%Feed.Delay) || (!%Feed.Chans) { echo -a You must fill in all the boxes!!! | dialog RSSFeed2 | halt }
unset *.Temp
if (!$hget(RSSFeed)) { hmake RSSFeed 5 }
hadd RSSFeed $replace(%Feed.Name,$chr(32),-) $remove(%Feed.Link,$chr(32)) $replace(%Feed.Chans,$chr(32),$chr(44)) $remove(%Feed.Delay,$chr(32))
RSS.Feed $replace(%Feed.Name,$chr(32),-) $remove(%Feed.Link,$chr(32)) $replace(%Feed.Chans,$chr(32),$chr(44)) $remove(%Feed.Delay,$chr(32))
set %Global.Feed.List %Global.Feed.List $replace(%Feed.Name,$chr(32),-) }
unset %Feed.*
dialog -m RSSFeed1 RSSFeed1
}
if ($did == 10) { unset *.Temp %Feed.* | dialog -m RSSFeed1 RSSFeed1 }
On *:dialog:RSSFeed2:edit:*: {
if ($did == 1) { set %Feed.Name.Temp $did(RSSFeed2,1) }
if ($did == 3) { set %Feed.Link.Temp $did(RSSFeed2,3) }
if ($did == 4) { set %Feed.Delay.Temp $did(RSSFeed2,4) }
if ($did == 7) { set %Feed.Chans.Temp $did(RSSFeed2,7) }
}
alias -l RSS.timeout {
RSS.clear
}
alias -l RSS.clear {
unset %RSS*
sockclose RSS
.timer-RSS off
halt
}
On *:Text:!Rss.Status:#: {
var %timer.num = $timer(0),%timer.timer = 1
while (%timer.num) {
if ($left($timer(%timer.num),3) == rss) {
.timer 1 %timer.timer .msg $chan 08 $timer(%timer.num) = 04 $timer(%timer.num).com 02Next Check in09 $timer(%timer.num).secs 08Seconds
}
inc %timer.timer
dec %timer.num
}
}
On *:Text:!news *:#: {
if ($hget(iddata,$2)) {
set %link $hget(iddata, $2)
.msg $chan ---» 8 Link «---
.msg $chan Click here:13 %link
}
else { .msg $chan 4 ---» L'ID !news $2 non esiste! «--- }
}
alias -l RSS.Status {
var %timer.num = $timer(0)
while (%timer.num) {
if ($left($timer(%timer.num),3) == rss) { echo -at 08 $timer(%timer.num) = 04 $timer(%timer.num).com }
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 120 RSS.Feed $1 $2 $3 }
}
alias -l RSS {
set %RSS.chans $3
set %RSS.name $1
sockclose RSS
set %RSSsite $gettok($remove($2,https://),1,47)
set %RSSurl $remove($2,https://,%RSSsite)
if (!$hget(%RSSsite)) { hmake %RSSsite 10 }
set %RSS.Count 1
set %RSS.Max 4
sockopen -e RSS %RSSsite 443
.timer-RSS 1 20 RSS.timeout
}
on *:sockopen:RSS: {
sockwrite -nt $sockname GET %RSSurl HTTP/1.0
sockwrite -n $sockname User-Agent: Opera 9.6
sockwrite -n $sockname Host: %RSSsite $+ $CRLF $+ $CRLF
}
on *:sockread:RSS: {
if ($sockerr > 0) { echo -at There has been an error... >RSS1.0<>Sock Error< | RSS.clear }
else {
var %RSSvar | sockread %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) {
set %id $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9)
.msg $gettok(%RSS.Chans,%RSS.Output,44) 0,4 Breaking News $+ %RSS.Name $remove(%RSS.Title,;&,",>) ( !news %id )
hadd iddata %id $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><![CDATA[,$chr(7),]]></title>,$chr(7)),2,7)
}
if ($left(%RSSvar,7) == <title>) {
set %RSS.Title $remove(%RSSvar,<title>,<![CDATA[,$chr(7),]]>,</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 }
}
}
alias -l RSS.StartUp {
var %num = $hget(rssfeed,0).item, %delay = 5
while (%num) {
.timer 1 %delay RSS.Feed $hget(rssfeed,%num).item $gettok($hget(rssfeed,%num).data,1,32) $gettok($hget(rssfeed,%num).data,2,32) $gettok($hget(rssfeed,%num).data,3,32)
inc %delay 7
dec %num
}
}
alias -l flink {
var %find.link = $1-,%found.link
while ($left(%find.link,4) != https) && ($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 $replace(%space.check,&,&)
}
alias -l httpstrip {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
On *:Connect: {
if (!$hget(RSSFeed)) { hmake RSSFeed 5 }
RSS.StartUp
}
On *:Start: {
if (!$hget(RSSFeed)) { hmake RSSFeed 5 }
if ($isfile(RSSFeed.hsh)) { hload -s RSSFeed RSSFeed.hsh }
{
/hmake -s iddata 100
}
}
On *:Exit: {
if ($hget(RSSFeed)) { hsave RSSFeed RSSFeed.hsh }
hfree RSSFeed
}
On *:Disconnect: {
if ($hget(RSSFeed)) { hsave RSSFeed RSSFeed.hsh }
}
On *:Unload: {
hfree RSSFeed
}
menu * {
-
.RSSFeed1.0
..Dialogs:RSS1.0
..List Feeds:RSS.Status
-
}