Sha256: 364a166a6977513f4f4691deadd42919c3dfecd657cf0bb11e5a95d75b319c3c

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

require 'platform-api'

module Lita
  module Handlers
    class RestartElvis < Handler
      route /^restart elvis$/i,
            :restart_bot,
            command: true,
            help: { 'restart elvis' => 'asks the heroku API to bounce elvis' }

      BLOG_URL = 'https://whatsbradeating.tumblr.com'.freeze

      def heroku
        @_heroku ||= PlatformAPI.connect_oauth(ENV.fetch('HEROKU_OAUTH_TOKEN'))
      end

      def restart_dyno_named(dyno_name)
        heroku.dyno.restart_all(dyno_name)
      end

      def restart_bot(response)
        restart_dyno_named ENV.fetch('HEROKU_RESTARTABLE_APP_NAME')

        response.reply 'I may have restarted, IDK'
      end

      Lita.register_handler(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-restart-elvis-0.1.0 lib/lita/handlers/restart_elvis.rb