Created
January 25, 2016 09:52
-
-
Save kfigiela/daae213c946e487a7832 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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