slack-status
slack-status copied to clipboard
Change your presence, status, do not disturb and profile picture settings in multiple Slack workspaces.
Slack Status
Change your presence, status, do not disturb and profile picture settings in multiple Slack workspaces using only one command.
How it Works
In order to integrate with Slack, each integration needs a dedicated Slack App, meaning you are required to create
a dedicated Slack App for slack-status to work in your workspace.
Each Slack App receives a clientId and clientSecret - details with which we can initiate the OAuth2 flow.
Through this flow, an app can get certain permissions, as well as certain permissions to act on a user's behalf.
With slack-status we are particularly interested in getting our app to acquire permissions to act on a user's behalf,
so that we can change the user's status via Slack's API.
When we go through the OAuth2 flow, slack-status specifies by default that it only needs access to a couple of user
scopes (dnd:write, users.profile:write & users:write).
These scopes are tied to a user, so we get a dedicated user authorization token with which we can issue
API calls to change the user's status.
The user authorization token is stored strictly in a configuration file locally (by default in ~/.slack-status
).
Free Slack workspaces are limited to 10 apps, in order to reduce the number of apps in a workspace it is possible to share Slack App credentials (clientId and clientSecret) so that multiple people can use slack-status in your workspace. The token used to change a user's status, the user authorization token, is stored only locally and the Slack App that is created for slack-status only requires user scopes, getting access to the Slack App's clientId and clientSecret will not enable other user's to change your status.
The clientId and clientSecret are merely necessary to trigger the OAuth2 flow with which we can get the user's user authorization token. We do not need any other scopes which could cause security issues.
Install
Dependencies:
- Go
Install from source:
$ go install github.com/greenstatic/slack-status
Installing in a Slack Workspace
In case you are worried about all these tokens, please read the How it Works section to understand what is going on.
You will need to do this for each Slack workspace you wish to specify control using slack-status.
I do not yet have a Slack App (or access to an App's clientId & clientSecret)
- Visit https://api.slack.com/apps
- Click on Create New App, then follow From an app manifest. Select your desired workspace and hit Next.
- Replace the YAML manifest template with the following:
_metadata:
major_version: 1
minor_version: 1
display_information:
name: slack-status
settings:
org_deploy_enabled: false
socket_mode_enabled: false
token_rotation_enabled: false
oauth_config:
redirect_urls:
- http://localhost:3030
- Click Next, then Create to finish the app creation.
- Scroll to App Credentials and copy Client ID as well as Client Secret.
I have a Slack App now
Now that you have access to your Slack's App clientId
and clientSecret
, run:
$ slack-status init <workspace name> <clientId> <clientSecret>
This should trigger the OAuth2 flow. You should see a URL in the console, visit it your browser (that is logged into your slack workspace). You can review the scopes we are asking for, just click confirm.
Once you click confirm you should see a simple page saying that your User Authorization Token has been successfully required. You may close the browser tab now.
That's it.
In your config file (default: ~/.slack-status) there should be a new entry for the workspace you just initialized.
You may add a list of group
names to the configuration workspace entry if you like.
Try to set your status now:
$ slack-status set -w <workspace name> -m "i'm using slack-status!" --emoji :tada: -d 5m
Usage
Set your status in Slack.
To setup the required authentication token(s) read the "init" subcommand help.
To set your status see the "set" subcommand.
Source code: https://github.com/greenstatic/slack-status
Usage:
slack-status [flags]
slack-status [command]
Available Commands:
help Help about any command
init Initialize slack-status in a workspace
set Set a custom slack status
version Show version
Flags:
-c, --config string Config file (default "~/.slack-status")
-h, --help help for slack-status
Use "slack-status [command] --help" for more information about a command.
Examples
Set your custom status to busy working on super secret project:
slack-status set -m "busy working on super secret project"
Set your custom status to programming for 45 min and turn on do not disturb for your my_job Slack workspace:
slack-status set -m "programming" -d 45m --dnd --workspace my_job
Set your custom status to lectures with custom books emoji for 2h 45m and turn on do not disturb for your work group Slack workspaces:
slack-status set -m "lectures" -d 2h45m --dnd --emoji ":books:" -g work
Clears your status and sets it back to Active:
slack-status set
Set your custom status to driving and custom car emoji with new profile picture in ~/driving.jpeg:
slack-status set -p ~/driving.jpeg -m "driving" --emoji :car:
Configuration
By default slack-status
will create a config in ~/.slack-status
but you can override this behaviour by setting the
path to the config explicitly using the --config
flag.
# Example slack-status config
workspaces:
- name: my_job
user: "<USER ID>"
accessToken: "<USER ACCESS TOKEN>"
groups:
- "work"
- name: home
user: "<USER ID>"
accessToken: "<USER ACCESS TOKEN>"
groups:
- "personal"
In general, you do not need to change anything, but you are encouraged to set your group
fields to your liking.