Sha256: 2970085534c8fcb73bd7cf745af49998c59963958323d566be18caf96076f220

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

module Socrates
  module Bots
    class Slack
      class Ping
        def initialize
          logger = Logger.new($stdout)
          # The ping is going to run every minute, so don't be too chatty
          logger.level = Logger::WARN

          @client = ::Slack::Web::Client.new(
            token: ENV.fetch("SLACK_API_TOKEN"),
            logger: logger
          )
        end

        def alive?
          auth = client.auth_test
          presence = client.users_getPresence(user: auth["user_id"])
          presence.online?
        end

        private

        attr_reader :client
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socrates-0.1.26 lib/socrates/bots/slack/ping.rb