Sha256: d3fccf0054735da28458a02e486275c05f64d881135d6e8419f14080d2ba84ea
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'open-uri' require 'rss' module Cinch module Plugins class Rss include Cinch::Plugin set :plugin_name, 'rss' set :help, <<EOT The RSS plugin will poll rss feed every 5 minutes EOT timer 300, method: :fetch_rss def new(bot) @bot = bot @feeds = [] end def fetch_rss @feeds ||= {} @bot.config.options['cogconf']['rss']['channels'].each do |chan| prefix = chan['prefix'] open(chan['url']) do |rss| feed = RSS::Parser.parse(rss) @feeds[prefix] ||= [] feed.items.reverse.each do |item| unless @feeds[prefix].include? item.link @feeds[prefix] << item.link # to prevent the first run displays all the items if @feeds[prefix].length > feed.items.length chan['announce'].each do |announce| Channel(announce).send "#{prefix} #{item.title} (#{item.link})" end end end end if @feeds[prefix].length > feed.items.length @feeds[prefix] = @feeds[prefix][-feed.items.length, feed.items.length] end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cogbot-0.1.6 | plugins/rss.rb |