From d189de477fe72f03ec695913121bc59be3e08e3a Mon Sep 17 00:00:00 2001 From: Jeff Mark Date: Sat, 10 Mar 2018 10:24:14 -0800 Subject: [PATCH 1/3] - added SLACK_INTERVAL to env vars - added env vars info to readme - change default interval to 15sec (5sec was causing rate limit errors from slack) --- .gitignore | 3 +++ lib/index.js | 2 +- package.json | 4 +++- readme.md | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 22f7aa01..39f3f8f0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ node_modules # logs npm-debug.log + +# Env +.env diff --git a/lib/index.js b/lib/index.js index b4d3b6cc..09a6cc06 100644 --- a/lib/index.js +++ b/lib/index.js @@ -21,7 +21,7 @@ import log from './log' export default function slackin ({ token, - interval = 5000, // jshint ignore:line + interval = 15000, // jshint ignore:line org, gcaptcha_secret, gcaptcha_sitekey, diff --git a/package.json b/package.json index 7ac64270..c22a2b5c 100644 --- a/package.json +++ b/package.json @@ -69,10 +69,12 @@ "gulpfile.babel.js" ], "env": [ + "SLACK_INTERVAL", "SLACK_API_TOKEN", "SLACK_SUBDOMAIN", "GOOGLE_CAPTCHA_SECRET", "GOOGLE_CAPTCHA_SITEKEY" - ] + ], + "dotenv": ".env" } } diff --git a/readme.md b/readme.md index 9e081aaf..203fcf2a 100644 --- a/readme.md +++ b/readme.md @@ -24,6 +24,25 @@ Other platforms: - [OpenShift](https://github.com/rauchg/slackin/wiki/OpenShift) - [IBM Bluemix](https://bluemix.net/deploy?repository=https://github.com/rauchg/slackin) +### Environment Variables + +These environment variables can be used to configure the app. + +```bash +# Time in milliseconds to ping the slack api +SLACK_INTERVAL=15000 + +# Slack team id (subdomain of slack.com) +SLACK_SUBDOMAIN= + +# Slack api token of your slack app with admin permission +SLACK_API_TOKEN= + +# Google reCAPTCHA keys +GOOGLE_CAPTCHA_SITEKEY= +GOOGLE_CAPTCHA_SECRET= +``` + ### Tips Your team id is what you use to access your login page on Slack (eg: https://**{this}**.slack.com). From 966c56530934f4ad417a8b0e9442e2c9c100fdb8 Mon Sep 17 00:00:00 2001 From: Jeff Mark Date: Sat, 10 Mar 2018 10:31:49 -0800 Subject: [PATCH 2/3] update slack interval default to 15s --- bin/slackin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/slackin b/bin/slackin index be0708b4..7e122fac 100755 --- a/bin/slackin +++ b/bin/slackin @@ -8,7 +8,7 @@ args .option(['p', 'port'], 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000) .option(['h', 'hostname'], 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0') .option(['c', 'channels'], 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS) - .option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000) + .option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 15000]', process.env.SLACK_INTERVAL || 15000) .option(['P', 'path'], 'Path to serve slackin under', '/') .option(['s', 'silent'], 'Do not print out warns or errors') .option(['x', 'cors'], 'Enable CORS for all routes') From 73330b6798f308e5feaed8bfe448b4e633e0865e Mon Sep 17 00:00:00 2001 From: Jeff Mark Date: Sat, 10 Mar 2018 10:40:37 -0800 Subject: [PATCH 3/3] make sure the ping interval to the slack api is no less than 5sec. --- lib/slack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/slack.js b/lib/slack.js index 5de4306e..cd7d0ca5 100644 --- a/lib/slack.js +++ b/lib/slack.js @@ -7,7 +7,7 @@ export default class SlackData extends EventEmitter { super() this.host = host this.token = token - this.interval = interval + this.interval = interval < 5000 ? 15000 : interval // Prevent pings of less than 5sec intervals this.ready = false this.org = {} this.users = {}