Skip to content

Instantly share code, notes, and snippets.

@ethagnawl
Created August 22, 2014 12:37
Show Gist options
  • Save ethagnawl/2acc29ea2508cd58a200 to your computer and use it in GitHub Desktop.
Save ethagnawl/2acc29ea2508cd58a200 to your computer and use it in GitHub Desktop.
Buckethead Tour Date Watcher
require 'pry'
require 'crimp'
require 'net/smtp'
def send_notification(opts={})
body = <<BODY_END
It appears Buckethead has announced new tour dates!
http://bucketheadland.com/tour/index.html
BODY_END
opts[:to] ||= '[email protected]'
opts[:server] ||= 'localhost'
opts[:from] ||= '[email protected]'
opts[:from_alias] ||= 'Buckethead Tour Dates'
opts[:subject] ||= "[Buckethead] New Tour Dates"
opts[:body] ||= body
msg = <<END_OF_MESSAGE
From: #{opts[:from_alias]} <#{opts[:from]}>
To: <#{opts[:to]}>
Subject: #{opts[:subject]}
#{opts[:body]}
END_OF_MESSAGE
Net::SMTP.start(opts[:server]) do |smtp|
smtp.send_message msg, opts[:from], opts[:to]
end
end
old_html = File.read 'tour.html'
old_signature = Crimp.signature old_html
`wget http://bucketheadland.com/tour/index.html -O tour.html`
new_html = File.read 'tour.html'
new_signature = Crimp.signature new_html
puts old_signature == new_signature
send_notification unless old_signature == new_signature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment