Cobi's RSS Poster Updated

By NIGathan on Jul 02, 2008

Cobi wrote this script: RSS Poster here: http://www.mirc.net/projects.php?view_snippet=1118356978

Now as I loaded it into my bot, the first thing I noticed was its all aliases so i changed them to on TEXT's then I noticed that you can't view a specific feed on request. So I wrote my own function which does just that. It may be slightly buggy considering the amount of feeds you use but nothing that cant be fixed with these commands "!rehashrss" and "!rsslist".

Installation:

Copy and paste into Remote. Don't forget to change the channel from #rss to whatever channel you want it to display in. I would write a function to do this through an alias but I'm kinda tired right now...

Creators Notes:

;==================================================
; RSS Poster
; by Cobi
;==================================================
; Commands:
; /rss Starts the rss poster (shortcut for /loadrsshist and /rsscfg)
; /addrss name host webfile channel count interval -- adds feed to rss.cfg (Implies /rsstimer)
; /showrss name host webfile channel count -- shows rss feed in channel (Implies /getrss and /parserss)
;
; ----- The following are internal commands and should only be used if messing around with the code. -----
; /loadrsshist Loads the history file so as not to post the same stuff over and over
; /closersshist Unloads the history file...
; /reloadrsshist Shortcut for /closersshist and /loadrsshist
; /rsscfg Loads rss.cfg file and parses it (Implies /rsstimer on every rss feed listed)
; /rsstimer name host webfile channel count interval starts a rss timer for the specified settings
; (Implies /showrss each interval)
; /getrss name host webfile file done -- downloades an rss feed then runs done when it is done (Implies /fixrss)
; /fixrss file -- fixes rss feed format. This is done automatically, and should only be done when debugging.
; /parserss file name channel count -- parses rss file and displays it in a channel
;
; Arguements:
; name = Name of feed (used for displaying purposes)
; host = Where to get the feed ( http://hostwebfile e.g. http://example.com/test.xml example.com is the host and /test.xml is the webfile.. )
; webfile = file on host
; file = local rss file
; channel = channel to show rss postings in
; count = how many rss posts to show at once
; interval = how often (in seconds) to show rss posts
; done = what to do when done downloading file
;
; Examples:
;
; Add a few rss feeds:
; /addrss mirc.net mirc.net /rss.php?type=news #rss 6 600
; /addrss SourceForge images.feedstermedia.com /feedcache/ostg/sourceforge/rss_sfnews.xml #rss 6 600
; /addrss NPR www.npr.org /rss/rss.php?topicId=1001 #rss 6 600
; /addrss Moreover p.moreover.com /page?o=rss002&c=Top%20stories&wiz=230176 #rss 6 600
; /addrss Copyright www.copyright.gov /rss.xml #rss 6 600
; /addrss podcastingnews www.podcastingnews.com /index.xml #rss 6 600
; /addrss Infoworld www.infoworld.com /rss/news.xml #rss 6 600
; /addrss BarkerJr.Net barkerjr.net /rss?c=2;f=5 #RSS 2 600
; /addrss Linux-Security www.linuxsecurity.com /static-content/linuxsecurity_hybrid.rdf #rss 6 600
; /addrss Planet-Source-Code www.planet-source-code.com /vb/channel/NewCode/channel.cdf #rss 6 600
; /addrss /. slashdot.org /rss/index.rss #rss 6 600
; /addrss ZDnet news.zdnet.com /2509-1_22-0-20.xml #rss 6 600
; /addrss IRC101 www.irc101.org /tier2.xml #rss 6 600
; /addrss MSDN msdn.microsoft.com /msdnmag/rss/recent.xml #rss 6 600
; /addrss Microsoft www.microsoft.com /communities/rss.aspx?&Title=Recent+Posts&CMTYSvcSource=MSCOMBlogPosts&CMTYRawShape=list&Params=%7eCMTYDataSvcParams%5e%7eArg+Name%3d'DateFormat'+Value%3d'MMM+d%2c+yyyy'%2f%5e%7e%2fCMTYDataSvcParams%5e&NumberOfItems=50 #rss 6 600
; /addrss &color;01,00W&color;00,01I&color;01,00R&color;00,01E&color;01,00D&color; wired.com /news/feeds/rss2/0,2610,,00.xml #rss 6 600
; /addrss RTCW ict.mcast.edu.mt /ictweb/davidmica/web/rss.xml #rss 6 600
; /addrss jaos software.jaos.org /cgi-bin/rss #rss 6 600
;
; Reload the config file:
; /rehashrss
;
; Edit the config file:
; /run notepad rss.cfg
;
; Load the config file and start posting news:
; /rss
;
; Contact:
; Cobi@winbots.org
; Cobi on Undernet (#phase, #rss, #game-trivia)
; Cobi on Winbots (#winbots)
; Cobi-Wan-Kenobi on Quakenet (#icechat)
; Cobi on SearchIRC Forums
; Winbots on UnrealIRCd Forums
; Cobi on mirc.net
;
; ChangeLog:
; v1.3 -- fixed memory bug
; v1.2 -- fixed the issue when the tags are not one word (

blah)
; v1.1 -- fixed rss.performance issue
; v1.0 -- Initial Release

My Notes:

Changed !list to !rsslist so it doesnt interfere with service bots.
Added an on TEXT for the following aliases incase your loading it through a bot:
/rehashrss = !rehashrss
/rss = !rss
/rssoff = !rssoff
Added a "!show " command. Put the title of the feed (the ones mentioned in !rsslist) in the parameter and all the news from that feed will be posted into the rss channel.
Added a !help command which displays the commands.
Added an on JOIN notice to users welcoming them with a tip to get them started.

on *:TEXT:!rss:#rss: { loadrsshist | rsscfg }
alias rss { loadrsshist | rsscfg }
alias closersshist { window -c @rss.hist | window -c @rss.performance }
alias reloadrsshist { closersshist | loadrsshist }
alias rsscfg {
  var %time = $ticks
  var %lcv2 = 0
  var %lcv = 1
  var %lines = $lines(rss.cfg)
  unset %list
  while (%lcv <= %lines) {
    if ($read(rss.cfg,%lcv)) {
      bunset &line
      bset -t &line 1 $read(rss.cfg,%lcv)
      if ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,<(.+)>(.+)</.+>)) {
        bunset &rss. $+ $regml(RSS,1)
        bset -t &rss. $+ $regml(RSS,1) 1 $regml(RSS,2)
      }
      elseif ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,</item>)) {
        rsstimer $bvar(&rss.feed,1,$bvar(&rss.feed,0)).text $bvar(&rss.host,1,$bvar(&rss.host,0)).text $bvar(&rss.file,1,$bvar(&rss.file,0)).text $bvar(&rss.channel,1,$bvar(&rss.channel,0)).text $bvar(&rss.feeds,1,$bvar(&rss.feeds,0)).text $bvar(&rss.interval,1,$bvar(&rss.interval,0)).text
        set %list %list $replacex($bvar(&rss.feed,1,$bvar(&rss.feed,0)).text,&amp;,&,&quot;,",&nbsp;,$chr(32),&color;,,&bold;,,&underline,)
        bunset &line &rss.*
        inc %Lcv2
      }
    }
    inc %lcv
  }
  if ($window(@rss.performance)) {
    aline @rss.performance ---
    aline @rss.performance Parsed %lcv Config Lines ( $+ %lcv2 rss entries) (rss.cfg) in $calc(($ticks - %time)/1000) Seconds
  }
}
alias rsstimer {
  ;$1 = feed name
  ;$2 = host
  ;$3 = file
  ;$4 = channel
  ;$5 = max
  ;$6 = interval
  showrss $1 $2 $3 $4 $5
  .timerrss. $+ $1 0 $6 showrss $1 $2 $3 $4 $5
}
alias showrss {
  ;$1 = feed name
  ;$2 = host
  ;$3 = file
  ;$4 = channel
  ;$5 = max
  set %time. $+ $1 $ticks
  .remove " $+ $1 $+ .rss $+ "
  getrss $1 $2 $3 $replace($1 $+ .rss,$chr(32),_) parserss $replace($1 $+ .rss,$chr(32),_) $1 $4 $5
}
alias getrss {
  ;$1 = feed name
  ;$2 = host
  ;$3 = file
  ;$4 = save
  ;$5- = done
  set %rss. $+ $1 $+ .file $3
  set %rss. $+ $1 $+ .host $2
  set %rss. $+ $1 $+ .save $4
  set %rss. $+ $1 $+ .done $5-
  sockopen rss. $+ $1 $2 80
}
on *:SOCKOPEN:rss.*:{
  sockwrite -tn $sockname GET % [ $+ [ $sockname $+ .file ] ] HTTP/1.1
  sockwrite -tn $sockname Host: % [ $+ [ $sockname $+ .host ] ]
  sockwrite -tn $sockname Accept: *.*, */*
  sockwrite -tn $sockname Connection: close
  sockwrite -tn $sockname $crlf
}
on *:sockclose:rss.*:{ fixrss % [ $+ [ $sockname $+ .save ] ] | % [ $+ [ $sockname $+ .done ] ] | unset % $+ $sockname $+ .* }
on *:sockread:rss.*:{
  if ($sockerr) { echo 1 -a ERROR | return }
  if (% [ $+ [ $sockname $+ .status ] ] != downloading) {
    var %1 | sockread %1 | tokenize 32 %1
    if ($1 == HTTP/1.1) { if ($2 != 200 && $2 != 206) { echo 1 -a ERROR } }
    elseif ($1 == Content-Range:) { set % [ $+ [ $sockname $+ .size ] ] $gettok($3,-1,47) }
    elseif ($1 == Content-Type:) { return }
    elseif (!$1) {
      set % [ $+ [ $sockname $+ .status ] ] Downloading
      return
    }
  }
  else {
    var %1 = % [ $+ [ $sockname $+ .save ] ]
    :sockread
    sockread &1
    if (!$sockbr) { return }
    bwrite $+(",%1,") -1 &1
    unset % [ $+ [ $sockname $+ .resume ] ]
  }
}

alias fixrss {
  ;$1 = rss file
  var %file = $1
  bread $1 0 $file($1).size &file
  breplace &file 10 32 13 32
  write -c $1
  var %lcv = 1
  var %size = $bvar(&file,0)
  while (%lcv <= %size) {
    parserss2 $1 $bvar(&file,%lcv,500).text
    inc %lcv 500
  }
}

alias parserss {
  ;$1 = rss file
  ;$2 = feed name
  ;$3 = channel
  ;$4 = max
  var %time = $ticks | var %lcv = 1 | var %lcv2 = 0 | var %lines = $file($1).size
  bread $1 0 %lines &file1
  while ((%lcv <= %lines) && (%lcv2 < $4)) { bunset &line | bcopy -c &line 1 &file1 %lcv $calc($iif($bfind(&file1,%lcv,$crlf),$bfind(&file1,%lcv,$crlf),$calc(%lines + 1)) - %lcv) | var %lcv = $calc($iif($bfind(&file1,%lcv,$crlf),$bfind(&file1,%lcv,$crlf),$calc(%lines + 1)) + 2)
    if (($bvar(&line,0) < 300) && ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,<(.+)>(.+)</.+>))) { if (($regml(RSS,1)) && ($regml(RSS,2))) { bunset &rss. $+ $gettok($regml(RSS,1),1,32) | bset -t &rss. $+ $gettok($regml(RSS,1),1,32) 1 $regml(RSS,2) } }
    elseif (($bvar(&line,0) < 300) && ($regex(RSS,$bvar(&line,1,$bvar(&line,0)).text,</item>))) { checkalreadyrss $3 [[ $+ $2 $+ ]] $+ 10 $bvar(&rss.title,1,$bvar(&rss.title,0)).text  $+ (14 $bvar(&rss.link,1,$bvar(&rss.link,0)).text ) | inc %lcv2 | bunset &line &rss.* }
  }
  if ($window(@rss.performance)) {
    aline @rss.performance ---
    aline @rss.performance Parsed %lcv Bytes ( $+ %lcv2 rss entries) ( $+ $1 $+ ) in $calc(($ticks - %time)/1000) Seconds
  }
  if (%time. [ $+ [ $2 ] ]) { if ($window(@rss.performance)) {
aline @rss.performance Downloaded and Parsed %lcv Bytes ( $+ %lcv2 rss entries) ( $+ $1 $+ ) in $calc(($ticks - %time. [ $+ [ $2 ] ] )/1000) Seconds } | unset %time. $+ $2 } }

alias addrss {
  ;$1 = feed name
  ;$2 = host
  ;$3 = file
  ;$4 = channel
  ;$5 = max
  ;$6 = interval
  write rss.cfg <item>
  write rss.cfg $chr(32) $+ $chr(32) $+ <feed> $+ $1 $+ </feed>
  write rss.cfg $chr(32) $+ $chr(32) $+ <host> $+ $2 $+ </host>
  write rss.cfg $chr(32) $+ $chr(32) $+ <file> $+ $3 $+ </file>
  write rss.cfg $chr(32) $+ $chr(32) $+ <channel> $+ $4 $+ </channel>
  write rss.cfg $chr(32) $+ $chr(32) $+ <feeds> $+ $5 $+ </feeds>
  write rss.cfg $chr(32) $+ $chr(32) $+ <interval> $+ $6 $+ </interval>
  write rss.cfg </item>
  rsstimer $1 $2 $3 $4 $5 $6
}
on *:TEXT:!rehashrss:#rss: {
  timerrss.* off
  rsscfg
}
alias rehashrss {
  timerrss.* off
  rsscfg
}
on *:TEXT:!rssoff:#rss: {
  timerrss.* off
  closersshist
}
alias rssoff {
  timerrss.* off
  closersshist
}
on 100:TEXT:!addrss * * * * * *:{ addrss $2 $3 $4 $5 $6 $7 }
alias checkalreadyrss {
  if (sponsored isin $1-) { goto done }
  if ($file(rss.hist.tmp)) { .remove rss.hist.tmp }
  filter -ffc rss.hist rss.hist.tmp * $+ $strip($1-) $+ *
  if ($file(rss.hist.tmp)) { .remove rss.hist.tmp }
  if ($filtered > 0) { goto done }
  write rss.hist $strip($1-)
  ;  if (!$window(@rss.hist)) { echo 4 -a $nopath($script) $+ : ERROR: no history loaded... (try /loadrsshist) | halt }
  ;  aline @rss.hist $strip($1-)
  msg $replacex($1-,&amp;,&,&quot;,",&nbsp;,$chr(32),&color;,,&bold;,,&underline,)
  :done
}
alias loadrsshist {
  if (!$file(rss.hist).size) { write rss.hist History File }
  ;  .window -k0lh @rss.hist
  ;  .loadbuf @rss.hist rss.hist
  ;  .window -k0 @rss.performance
}
alias parserss2 {
  ;$1 = File
  ;$2- = XML data
  var %file = $1
  ;[Code by FiberOPtics] Thanks.. :P
  var %a, %b = $regsub($2-,/(?<=>)(?=s*<)/g,$lf,%a)
  tokenize 10 %a
  ;[/Code by FiberOPtics]
  var %lcv = 1
  while (%lcv <= $0) {
    bset -t &tmp $calc($bvar(&tmp,0) +1) $ [ $+ [ %lcv ] ] $+ $crlf
    inc %lcv
  }
  bwrite %file -1 $calc($bvar(&tmp,0) -2) &tmp
  bunset &tmp
}
on *:TEXT:!rsslist:#rss:{ msg $chan I syndicate the following: | msg $chan %list }
alias rsslist { msg $chan I syndicate the following: | msg $chan %list }

on *:TEXT:!show *:#rss: {
  if ($2) {
    %rssin = $replace($2-,$, )
    %rssinput = * $+ %rssin $+ *
    if (%rssin isin %list) {
      while $read(rss.hist, w, %rssinput) != $null {
        write -dw * $+ $2- $+ * rss.hist
      }
      rehashrss
    }
    else {
      msg # Sorry, I do not syndicate that feed.
    }
  }
  else {
    msg # What feed would you like to see?
    rsslist
  }
}

on *:JOIN:#RSS: {
  notice $nick Welcome to #RSS! I will be delivering the news here. Say "!help" to get started.
}

on *:TEXT:!help:#RSS: {
  msg # To see a list of feeds use "!rsslist"
  msg # To check for any updates use "!rehashrss"
  msg # To view a specific feed use "!show <feed>"
}

Comments

Sign in to comment.
dma   -  Dec 14, 2015

this does not work anymore in 2015!

 Respond  
cptpan   -  Jul 13, 2012

Your link is 404.

Where can I find a working mIRC rss reader for fucks sake

 Respond  
Pangaea   -  Apr 06, 2012

um.. came across one of fords oldies http://www.wyldryde.org/forum/ubbthreads.php/topics/4446/Simple_RSS_Feed_Script.html
Seems to be working (so far)..
I am getting a "![CDATA[" prefixing the title tho, not sure if its meant to be a date and time..
anyway i should be ok with this for a bit
cheers

 Respond  
Pangaea   -  Apr 06, 2012

Hi cobi, I dont suppose uve updated this script in anyway since your last post? Ive run into trouble with these rss feeds again, had fords one working but now it doset seem to work any more.. I know i had trouble with yours in the past, but im trying this on a few diff client versions to see if i can get it working.
The recurring error on clients is:

  • /remove: unable to remove 'C:Program FilesMIRC5Forum-News:.rss' (line 50, RSS)

Am i entering this correctly?
/addrss Forum-News: www.fractalforums.com index.php?action=.xml;board=;type=rss #FractalForums 6 60

its for this rss page:
http://www.fractalforums.com/index.php?action=.xml;board=;type=rss

Perhaps if someone is using cobi's with success can they test that link out for me? if it works, what client version is it working for you on?

anyhow...

regards

 Respond  
cptpan   -  Feb 19, 2012
  • /timerrss.myfeedwashere: invalid parameters (line 41, script8.mrc)
 Respond  
Pangaea   -  Dec 30, 2011

so, anyway... i open up the rss.cfg file, and strip down all the bogey entries this script made so im now left with this:

http://www.physnews.com/

so this is the entry it made for that feed, as you can clearly see all its done is added in the url.. like wtf?
so assuming i can add these feeds in manually.
lets go thru these one by one.

http://www.physnews.com/ = right so i can only assume the url goes here (as the script added itself) = no idea what goes here.. the url again? or the full url to the feed? again no idea = file? what file? rss.cfg? ... completely clueless as to what goes here = I assume the channel name goes here = um, didnt we already do this? no idea what to put in here = I assume the timing interval goes here if someone else managed to get this working can they please paste an example of their rss.cfg so I can work out how to manually enter feeds rather then using the non working /addrss command.
 Respond  
Pangaea   -  Dec 30, 2011

yet another totaly non working rss feed... can somone please for the love of odin make a working rss feed in 2012... make 2012 special for alot of ppl

bleh bleh

  • /sockwrite: 'rss.PhysicsNews' not connected (line 66, -----rss)
  • /msg: insufficient parameters
  • /bset: insufficient parameters (line 117, -----rss)
  • /msg: insufficient parameters
  • /sockwrite: 'rss.PhysicsNews' not connected (line 66, -----rss)

bleh bleh

Pangaea> !show physicsnews

Sorry, I do not syndicate that feed. !rsslist I syndicate the following: ........ bleh bleh /addrss PhysicsNews http://www.physorg.com/xml-feed/physics-news/ #PhysicsTrivia 2 20 /addrss PhysicsNews www.physorg.com /xml-feed/physics-news/ #PhysicsTrivia 2 20 /addrss PhysicsNews http://feeds.feedburner.com /physicstoday/pt1?format=xml #PhysicsTrivia 2 20 /addrss PhysicsNews www.physorg.com /xml-feed/physics-news/physics/ #PhysicsTrivia 2 20 /timerrss.physicsnews: invalid parameters (line 41, -----rss) * /sockopen: 'rss.PhysicsNews' socket in use (line 63, -----rss) then using your top example: /addrss testfeed mirc.net /rss.php?type=news #PhysicsTrivia 2 20 status: * /msg: insufficient parameters no go no go no go.. bleh bleh ,, same old rss story, as perennial as the grass happy new year all pan
 Respond  
ghostwarrior   -  Aug 16, 2010
  • /bset: insufficient parameters (line 119, RSS)
  • /bset: insufficient parameters (line 119, RSS)

there a fix for this?

 Respond  
Askeen   -  Feb 20, 2010

I can't get this working.

 Respond  
NXArmada   -  Feb 10, 2010

Thats cause the other only made it work in one channel - #rss

on *:TEXT:!rss:#rss:
 Respond  
camti   -  Jun 06, 2009

Hi cobi,

the RSS feed is working, i can see that in the .rss files it is creating (in my bot's directory) however, when requested in a channel, it's just blank, nothing happens?
Any ideas?

Thanks.

 Respond  
PATX   -  Mar 15, 2009

nice. i think i am going to change this into a script that can tell me when new posts are made at patx.pastebin.com then post them to my chan :) gets a 7

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.