class Cinch::Plugins::Starcraft::FeedsReader
Public Class Methods
new(bot, channels)
click to toggle source
# File lib/cinch/plugins/starcraft/feeds.rb, line 5 def initialize(bot, channels) @bot, @channels = bot, channels @feeds = Feedzirra::Feed.fetch_and_parse( User.all.map { |u| u.feed } ) end
Public Instance Methods
start()
click to toggle source
# File lib/cinch/plugins/starcraft/feeds.rb, line 10 def start loop do sleep $config['rss']['interval'] begin @feeds = Feedzirra::Feed.update(@feeds.values) @feeds.each do |feed| feed = feed[1] nick = User.find_by_username( feed.title.split(" ").last ).nick entries = feed.new_entries[0..($config['rss']['floodlines']-1)] entries.each do |entry| msg = "#{nick} just played #{entry.title}" @bot.dispatch(:rss_update, nil, {:channels => @channels, :message => msg }) end end rescue Exception => e puts e # Probably no feeds to refresh end end end