Skip to content

Instantly share code, notes, and snippets.

@kfigiela
Created January 25, 2016 09:52
Show Gist options
  • Save kfigiela/daae213c946e487a7832 to your computer and use it in GitHub Desktop.
Save kfigiela/daae213c946e487a7832 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "slack"
Slack.configure do |config|
config.token = ENV['SLACK_TOKEN']
end
channel = ENV['SLACK_CHANNEL']
# Slack.auth_test
cl = Slack.client
users = cl.users_list presence: true
present = users["members"].select { |u| u["presence"] == "active" }.map {|u| "@" + u["name"]}
if present.length > 0
msg = "#{present.join(", ")} – jest #{Time.now.strftime "%H:%M"}, pora spać!"
cl.chat_postMessage channel: channel, text: msg, username: "SleepBot", icon_emoji: ":sleeping:"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment