-
-
Save kkosuge/af5894ced5cc1ac38bfd2687cad7c780 to your computer and use it in GitHub Desktop.
Slack のステータス変更スクリプト
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
| SLACK_TOKEN=lgsolashdgoalisdhgaldgahksdg |
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
| 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 |
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
| 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