mendicant-university/mendibot — Issue #27: Mendibot should post links to new Community articles
Author: gjp
Created: 2012-01-29 03:55:05+00:00
State: open

per @sandal's email:

> 1) Have mendibot monitor the community website RSS feed and post links to new articles as they get posted to the site.

here's another small hack (minus the facepalm code written before I realized Cinch has timers). Should the constants reside within the plugin rather than Mendibot::Config? All suggestions welcome.

````
class CommunityRSS
include Cinch::Plugin

timer Mendibot::Config::RSS_INTERVAL, method: :pull

def pull
open(Mendibot::Config::RSS_URL) do |rss|

feed = RSS::Parser.parse(rss)
min_time = Time.now - Mendibot::Config::RSS_INTERVAL

feed.items.each do |item|
if item.pubDate >= min_time
Mendibot::Config::CHANNELS.each do |chan|
Channel(chan).send "Community post by #{item.author}: #{item.link}"
end
end
end
end

rescue Exception => e
bot.logger.debug e.message
end

end
````