Skip to content

kcapp/slack-announcer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kcapp logo

slack-announcer

Simple node script listening for certain events on socket.io and announce them in a Slack channel

Example

Match Started

Once a official match starts, a message will be posted showing the two players and a link to spectate the match

Match Started

Match Thread

For each leg finishing, a message will be posted to the thread of the original message, showing who won the leg, with what checkout and after how many darts

Match Thread

Match Ended

Once the match finishes, the original messag will be updated with the final result, as well as a link to the match result

Match Ended

Install

  1. Install all dependencies npm install
  2. Verify your integration with the following command, it will post a test message to verify the integration
SLACK_CHANNEL=<channel_id> SLACK_KEY=<oauth_token> npm start verify
  1. Run with
ANNOUNCE=true SLACK_CHANNEL=<channel> SLACK_KEY=<key> DEBUG=kcapp* npm start
# ... or
SLACK_CHANNEL=<channel> SLACK_KEY=<key> npm run prod
# ... or for development (will not actually post anything)
npm run dev

Configuration

To make the slack-announcer work it must be linked to a Slack app, see below section for Slack setup

Configuration is done via the following environment variables

  • ANNOUNCE: By default no messages are posted, so this must be set to true to post. If not messages will only be logged out for debugging
  • SLACK_CHANNEL: ID of the Slack channel to post to
  • SLACK_KEY: Bot User OAuth Access Token
  • DEBUG: value is passed to debug module to specify which packages should be logged
  • GUI_URL: This is used for all links posted on Slack, defaults to http://localhost:3000

If you are running on non-standard setup, you might also need to specify

  • API_URL: By default it assumes the API is running on http://localhost:8001
  • KCAPP_HOST: Host of kcapp socketio, default to localhost
  • KCAPP_PORT: Port of kcapp socketio, default to 3000
  • KCAPP_PROTO: Protocol, default to http

Service

To run this as a service see kcapp-announcer.service

Slack setup

  1. Create a new Slack App with the following App Manifest
display_information:
  name: kcapp
  description: Dart Scoring Application
  background_color: "#2c2d30"
features:
  bot_user:
    display_name: kcapp
    always_online: true
oauth_config:
  scopes:
    bot:
      - channels:read
      - chat:write
      - groups:read
      - reactions:read
      - reactions:write
settings:
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false
  1. Install the app into your workspace