Class: Socrates::Bots::Slack::Ping
- Inherits:
-
Object
- Object
- Socrates::Bots::Slack::Ping
- Defined in:
- lib/socrates/bots/slack/ping.rb
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize ⇒ Ping
constructor
A new instance of Ping.
Constructor Details
#initialize ⇒ Ping
Returns a new instance of Ping.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/socrates/bots/slack/ping.rb', line 5 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 |
Instance Method Details
#alive? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/socrates/bots/slack/ping.rb', line 16 def alive? auth = client.auth_test presence = client.users_getPresence(user: auth["user_id"]) presence.online? end |