2.2.2 • Published 2 years ago

slackin-extended v2.2.2

Weekly downloads
11
License
MIT
Repository
github
Last release
2 years ago

npm version Build Status MIT License LGTM Alerts

Features

Slackin-extended is a more customizable and extendable fork of the original slackin.

  • A landing page you can point users to fill in their emails and receive an invite (https://slack.yourdomain.com)
  • An <iframe> badge to embed on any website that shows connected users in realtime with socket.io.
  • A SVG badge that works well from static mediums (like GitHub README pages)
  • Abuse prevention via Google reCAPTCHA, including Invisible reCAPTCHA.
  • Color scheme customization on both the landing page and the badge.

Check out the Demo, which is deployed live from the master branch. For the list of changes in slackin-extended see HISTORY.md.

Disclaimer: this project is not affiliated with Slack. The Slack logo and Slack API are copyright Slack Technologies, Inc.

Installation

Heroku

Deploy

Now

Set up Now on your device and run it! If you don't have an .env file for your Now deployment (see environment variables and secrets), you can just set the two required parameters through now secrets:

git clone https://github.com/emedvedev/slackin-extended.git
now secrets add slack-subdomain "myslack"
now secrets add slack-api-token "xoxb-YOUR-SLACK-TOKEN"
now slackin-extended

Docker

The Docker container is available on Docker Hub: emedvedev/slackin-extended.

npm

To host Slackin-extended yourself, install it via npm and launch it on your server:

npm install -g slackin-extended
slackin "workspace-id" "your-slack-token"

Usage

Badges

Realtime (demo)

<script async defer src="https://slack.yourdomain.com/slackin.js"></script>
<!-- append "?large" to the URL for the large version -->

SVG (demo)

<img src="https://slack.yourdomain.com/badge.svg">

By default, the badge background color will be set to your accent color, but you can customize both background and text colors through the query string:

<img src="https://slack.yourdomain.com/badge.svg?bg=e01563&fg=ffffff">

Parameters

Every CLI parameter, including mandatory arguments (workspace ID and token), can alternatively be configured through environment variables.

FlagShortEnvironment variableDefaultDescription
Positional 1SLACK_SUBDOMAINRequiredSlack workspace ID (https://**{this}**.slack.com)
Positional 2SLACK_API_TOKENRequiredAPI token
--port-pSLACKIN_PORT3000Port to listen on
--hostname-hSLACKIN_HOSTNAME'0.0.0.0'Hostname to listen on
--channels-cSLACKIN_CHANNELS''One or more comma-separated channel names to allow single-channel guests
--emails-eSLACKIN_EMAILS''Restrict sign-up to a list of emails (comma-separated; wildcards are supported)
--interval-iSLACKIN_INTERVAL60000How frequently (ms) to poll Slack
--path-PSLACKIN_PATH/Path to serve slackin under
--silent-sSLACKIN_SILENTfalseDo not print out warnings or errors
--cors-xSLACKIN_CORSfalseEnable CORS for all routes
--analytics-aSLACKIN_ANALYTICS''Google Analytics ID
--recaptcha-secret-RRECAPTCHA_SECRET''reCAPTCHA secret
--recaptcha-sitekey-KRECAPTCHA_SITEKEY''reCAPTCHA sitekey
--recaptcha-invisible-IRECAPTCHA_INVISIBLE''Use invisible reCAPTCHA
--theme-TSLACKIN_THEMElightColor scheme to use, light or dark
--accent-ASLACKIN_ACCENT#e01563 for light, #9a0e44 for darkAccent color to use instead of a theme default
--coc-CSLACKIN_COC''Full URL to a CoC that needs to be agreed to
--css-SSLACKIN_CSS''Full URL to a custom CSS file to use on the main page
SLACKIN_PAGE_DELAY0Delay (ms) between Slack API requests (may be required for large workspaces that hit the rate limit)
SLACKIN_PROXYfalseTrust proxy headers (only use if Slackin is served behind a reverse proxy)
SLACKIN_HTTPS_REDIRECT''If a domain name is specified in this parameter and SLACKIN_PROXY is set to true, Slackin will redirect requests with x-forwarded-proto === 'http' to https://<SLACKIN_HTTPS_REDIRECT>/<original URL>
SLACKIN_LETSENCRYPT''Let's Encrypt challenge response

Alternatively, you can specify the configuration parameters in a dotenv file: create a .env file in the root directory of your project and add environment-specific variables on new lines in the form of NAME=VALUE. For example:

SLACK_SUBDOMAIN=mysubdomain
SLACK_API_TOKEN=SLACK-API-TOKEN
SLACKIN_THEME=dark

Extras

Tips and tricks

  • Please use reCAPTCHA for your Slack to avoid request flooding by spambots. Here is where to get your secret and sitekey. Make sure you choose a v3 API key.

  • Invisible reCAPTCHA is recommended for the realtime badge users, as the regular CAPTCHA challenge is broken inside the iframe that opens on badge click.

  • You can find or generate your API test token at api.slack.com/web. Important notes:

    • you need a legacy token
    • the user you use to generate the token must be an admin. You need to create a dedicated @slackin-inviter user (or similar), mark that user an admin, and use a test token from that dedicated admin user. Note that test tokens have actual permissions so you do not need to create an OAuth 2 app. Also check out the Slack docs on generating a test token.
  • Important: If you use Slackin in single-channel mode, you'll only be able to invite as many external accounts as paying members you have times 5. If you are not getting invite emails, this might be the reason. Workaround: sign up for a free org, and set up Slackin to point to it (all channels will be visible).

Development

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Uninstall slackin if it's already installed: npm uninstall -g slackin-extended
  3. Link it to the global module directory: npm link
  4. Run it locally with npm run dev, after setting up the needed environment variables

Yay! Now can use the slackin command everywhere.

Extending templates and themes

If changing accent colors and switching between light/dark themes isn't enough for you, all templates are stored inside views/ and can be easily modified. Stylesheets are stored in scss/, and both themes have a documented example of colors, variables and additional styles necessary to create your own.

If you end up creating another theme, you're more than welcome to submit a PR!

API

Loading slackin will return a Function that creates a HTTP.Server instance:

const slackin = require('slackin-extended');

slackin({
  token: 'SLACK-API-TOKEN', // reqired
  org: 'your-slack-subdomain', // required
  interval: 60000, // polling interval for Slack servers
  path: '/some/path/you/host/slackin/under/', // defaults to '/'
  cors: false, // set to "true" to enable CORS
  recaptcha: {
    secret: 'RECAPTCHA-SECRET', // reCAPTCHA secret
    sitekey: 'RECAPTCHA-SITEKEY', // reCAPTCHA sitekey
    invisible: true, // enable Invisible reCAPTCHA
  },
  analytics: 'GOOGLE-ANALYTICS-ID', // Google Analytics ID
  theme: 'light', // color scheme: "light" or "dark"
  accent: 'teal', // accent color (for buttons, text accents, etc.)
  css: 'https://example.org/slackin-extra.css', // external CSS file to include
  channels: 'community-public,testing', // for single-channel mode
  emails: 'john@gmail.com,jane@gmail.com,*@johnandjane.com', // email whitelist
  coc: 'https://example.org/code-of-conduct', // code of conduct link
  proxy: false, // set to "true" if Slackin is set up behind a reverse proxy
  redirectFQDN: 'slack.myorg.com', // redirect requests with x-forwarded-proto === 'http' to this domain
  letsencrypt: 'LETSENCRYPT-CHALLENGE', // Let's Encrypt challenge
  silent: false, // suppress warnings
  server: http.Server(), // optional, allows passing in an existing http server object
}).listen(3000)

This will show response times from Slack and how many online users you have on the console. The returned http.Server has an app property that is the express application that you can define or override routes on.

All the metadata for your organization can be fetched via a JSON HTTP request to /data.

2.2.2

2 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

7 years ago