Sha256: 32a0d41c7b9718865abce4a989dc10b50ae36361128fde0283984dc8277621ba

Contents?: true

Size: 619 Bytes

Versions: 6

Compression:

Stored size: 619 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

6 entries across 6 versions & 1 rubygems

Version Path
socrates-0.1.25 lib/socrates/bots/slack/ping.rb
socrates-0.1.24 lib/socrates/bots/slack/ping.rb
socrates-0.1.23 lib/socrates/bots/slack/ping.rb
socrates-0.1.22 lib/socrates/bots/slack/ping.rb
socrates-0.1.21 lib/socrates/bots/slack/ping.rb
socrates-0.1.20 lib/socrates/bots/slack/ping.rb