Created
December 13, 2013 17:41
-
-
Save carlzulauf/7948122 to your computer and use it in GitHub Desktop.
Watch the SteamOS beta download URL. Alert me when its not a 404.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'logger' | |
require 'net/http' | |
require 'json' | |
require 'mail' # gem 'mail' | |
dir = File.dirname(__FILE__) | |
logger = Logger.new(File.join(dir, "log.txt")) | |
logger.level = Logger::INFO | |
# credentials.yml example: | |
# --- | |
# :user_name: some+user@gmail.com | |
# :password: muchdoge | |
# | |
credentials = YAML.load_file(File.join(dir, "credentials.yml")) | |
Mail.defaults do | |
delivery_method :smtp, credentials.merge( | |
address: "smtp.gmail.com", | |
port: "587", | |
authentication: :plain, | |
enable_starttls_auto: true | |
) | |
end | |
def send_notice(to) | |
Mail.deliver do | |
from "Steam Watcher <#{to}>" | |
to to | |
subject "SteamOS is out!" | |
body "Get it now, while you still can!\nhttp://steampowered.com/steamosbeta" | |
end | |
end | |
response = Net::HTTP.get_response URI("http://steampowered.com/steamosbeta") | |
logger.info "Response code: #{response.code}" | |
send_notice(credentials[:user_name]) if response.code != "404" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment