Create a gist now

Instantly share code, notes, and snippets.

@kkosuge /.env
Created Jul 24, 2017

What would you like to do?
Slack のステータス変更スクリプト
SLACK_TOKEN=lgsolashdgoalisdhgaldgahksdg
require 'json'
Bundler.require
Dotenv.load
emoji = ARGV[0]
text = ARGV[1]
def notify(title, message)
`osascript -e 'display notification "#{message}" with title "#{title}"'`
end
def set_status(status_emoji, status_text)
params = {
token: ENV['SLACK_TOKEN'],
profile: {
status_emoji: status_emoji,
status_text: status_text
}.to_json
}
res = Faraday.post('https://slack.com/api/users.profile.set', params)
res.success? && JSON.parse(res.body)['ok']
rescue => e
false
end
if set_status(emoji, text)
notify("#{emoji} #{text}", 'Slack の絵文字ステータスを更新しました')
else
notify('Failed to update emoji status', '')
end
source 'https://rubygems.org'
gem 'dotenv'
gem 'faraday'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment