class Ruboty::GithubStatus::Actions::GithubStatus

Public Instance Methods

last_message() click to toggle source
# File lib/ruboty/github_status/actions/github_status.rb, line 22
def last_message
  html = open('https://status.github.com/api/last-message.json').read
  json = JSON.parser.new(html).parse
  date = Time.parse(json['created_on']).getlocal

  msg = "Status: #{json['status']}\n"
  msg += "Message: #{json['body']}\n"
  msg += "Date: #{date}"

  message.reply(msg)
end
status() click to toggle source
# File lib/ruboty/github_status/actions/github_status.rb, line 8
def status
  html = open('https://status.github.com/api/status.json').read
  json = JSON.parser.new(html).parse
  now = Time.now
  date = Time.parse(json['last_updated']).getlocal
  p now
  p date
  seconds_ago = (now - date).to_i

  msg = "Status: #{json['status']} (#{seconds_ago} seconds ago)"

  message.reply(msg)
end