Skip to content

Instantly share code, notes, and snippets.

@dartov
Created May 18, 2017 21:25
Show Gist options
  • Save dartov/ae668d69a0c06cd118a940df00738c2b to your computer and use it in GitHub Desktop.
Save dartov/ae668d69a0c06cd118a940df00738c2b to your computer and use it in GitHub Desktop.
Sets custom status on Slack
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