Class: Ruboty::GithubStatus::Actions::GithubStatus

Inherits:
Actions::Base
  • Object
show all
Defined in:
lib/ruboty/github_status/actions/github_status.rb

Instance Method Summary collapse

Instance Method Details

#last_messageObject



22
23
24
25
26
27
28
29
30
31
32
# 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

#statusObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# 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