Sha256: e826b8d2c9222479562d74b4381bbc8aa9dbffd6d7be063d8af6465977b2b05d
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Lita module Handlers class ServerStatus < Handler MESSAGE_REGEX = %r/(?::eyes:)*\s*(.+) is deploying (.+)\/(.+) to (.+)/i route(MESSAGE_REGEX, :save_status) route(/server status/i, :list_statuses, command: true, help: { 'server status' => 'List out the current server statuses.' }) def save_status(response) message = response.message.body user, application, branch, environment = message.match(MESSAGE_REGEX).captures apply_status = { id: "#{application}:#{environment}", message: "#{application} #{environment}: #{branch} (#{user} @ #{formatted_time})" } redis.set("server_status:#{apply_status[:id]}", apply_status[:message]) end def list_statuses(response) response.reply status_message end def status_message messages = redis.keys('server_status*').sort.map { |key| redis.get(key) } messages << 'I don\'t know what state the servers are in.' if messages.empty? messages.join('\n') end def formatted_time Time.now.strftime('%Y-%m-%d %H:%M') end end Lita.register_handler(ServerStatus) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-server_status-1.0.0 | lib/lita/handlers/server_status.rb |