Created
May 18, 2017 21:25
-
-
Save dartov/ae668d69a0c06cd118a940df00738c2b to your computer and use it in GitHub Desktop.
Sets custom status on 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
use framework "Foundation" | |
use scripting additions | |
set statusText to "working remotely" | |
set statusEmoji to ":house_with_garden:" | |
-- legacy token is available at https://api.slack.com/custom-integrations/legacy-tokens | |
set token to "super-secret-token" | |
-- | |
set status to "{ \"status_text\": \"" & statusText & "\", \"status_emoji\": \"" & statusEmoji & "\" }" | |
set curlString to "curl 'https://slack.com/api/users.profile.set?token=" & token & "&profile=" & urlEncode(status) & "'" | |
do shell script curlString | |
on urlEncode(input) | |
tell current application's NSString to set rawUrl to stringWithString_(input) | |
set theEncodedURL to rawUrl's stringByAddingPercentEscapesUsingEncoding:4 | |
return theEncodedURL as Unicode text | |
end urlEncode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment