lib/lita/handlers/restart_elvis.rb in lita-restart-elvis-0.1.0 vs lib/lita/handlers/restart_elvis.rb in lita-restart-elvis-0.2.0

- old
+ new

@@ -13,16 +13,29 @@ def heroku @_heroku ||= PlatformAPI.connect_oauth(ENV.fetch('HEROKU_OAUTH_TOKEN')) end def restart_dyno_named(dyno_name) - heroku.dyno.restart_all(dyno_name) + result = heroku.dyno.restart_all(dyno_name) end + def dyno_info(app_name) + infos = heroku.dyno.list(app_name) + + infos.map { |i| "#{i.fetch('name')}\t#{i.fetch('state')}\tboot time: #{i.fetch('created_at')}" }.join("\n") + end + def restart_bot(response) - restart_dyno_named ENV.fetch('HEROKU_RESTARTABLE_APP_NAME') + app_name = ENV.fetch('HEROKU_RESTARTABLE_APP_NAME') - response.reply 'I may have restarted, IDK' + response.reply 'Please hold...' + + restart_dyno_named app_name + + sleep 5 + msg = dyno_info(app_name) + + response.reply "Done. Status: #{msg}" end Lita.register_handler(self) end end