Skip to content

stevennoto/slack-status

Repository files navigation

Slack Status

This is a simple app to help get or set your Slack status from the command line.

The app is a Spring Boot app written in Kotlin. It uses the Java Slack API client to read and set status info.

Setup

To use this app, you need a "user token" for the Slack API. This allows the app to take actions on your behalf. User token strings begin with xoxp-.

To create a user token, first create a Slack app, optionally following this tutorial. Then, find you app at https://api.slack.com/apps/ and click "OAuth & Permissions." Look under "User Token Scopes" and add scopes for users.profile:read and users.profile:write. Then reinstall the app when prompted, which will regenerate tokens. Then copy your "User OAuth Token" from the page.

You can then specify your token in an environment variable named $SLACK_API_TOKEN or with a token argument.

Build

To build the app, use Gradle:

./gradlew :bootJar

This should build a jar file in the build/libs folder.

Usage

Run the app with Java, for example, java -jar slack-status.jar.

Set your Slack API user token via environment variable SLACK_API_TOKEN or as --token=<token>.

Specify --get-status, --set-status, --clear-status, --get-channel-stats, or --help for mode:

java -jar slack-status.jar --get-status

Specify --text='some text' --emoji='emoji-name' when setting status, and optionally --expires='date/time':

java -jar slack-status.jar --set-status --text='Lunch break' --emoji='sandwich' --expires='1pm'

Specify --channel-id='Slack channel ID' --start='date/time' --end='date/time' when getting stats, and optionally --split-by='week|month':

java -jar slack-status.jar --get-channel-stats --channel-id='CXYZ123' --start='January 1, 2022 0:00' --end='January 31, 2022 23:59' --split-by='week'

Natty is used for natural language date parsing, so expressions like "tomorrow morning" or "wednesday at 5pm" will be recognized for date/time arguments.

TODO

  • Get token from env or arg
  • Improve results display
  • Add mode to display status
  • Add mode to clear status (empty strings to status_text and status_emoji)
  • Add 'help'/'usage' to cli and README
  • Add setting of expiration date, with shortcuts like "end of day"
  • Add saving/retrieving template statuses
  • Decide whether to keep Spring dependencies

About

Slack Status Setter app

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages