Platinum Partner

Simple Ruby Snarl RSS Alerter

This simple Ruby program will send a Snarl alert when a new post is added to a feed. Assumes your Snarl command line tool is named "snarl.exe" and in your PATH.


require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'

def snarl(title, msg)
  # This part actually sends the notification.
  # Change "snarl" to your snarl command line tool if you have problems
  system "snarl /M \"#{title}\" \"#{msg}\""
end

source = ARGV[0]
content = ''
open(source) { |s| content = s.read }
rss = RSS::Parser.parse(content, false)
puts rss.channel.title
puts rss.channel.link
puts rss.channel.description

last_item = nil

while true
  puts "Checking for updates..."
  open(source) { |s| content = s.read }
  rss = RSS::Parser.parse(content, false)
  if last_item == rss.items[0]
    sleep 5*60*1000
  else
    last_item = rss.items[0]
    snarl last_item.title + " (#{rss.channel.title})", last_item.description.gsub(/<\/?[^>]*>/, "")
    sleep 10*60*1000
  end
end
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}