Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configurable ping interval to slack api #363

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,6 @@ node_modules

# logs
npm-debug.log

# Env
.env
2 changes: 1 addition & 1 deletion bin/slackin
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/slack.js
Expand Up @@ -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 = {}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -69,10 +69,12 @@
"gulpfile.babel.js"
],
"env": [
"SLACK_INTERVAL",
"SLACK_API_TOKEN",
"SLACK_SUBDOMAIN",
"GOOGLE_CAPTCHA_SECRET",
"GOOGLE_CAPTCHA_SITEKEY"
]
],
"dotenv": ".env"
}
}
19 changes: 19 additions & 0 deletions readme.md
Expand Up @@ -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).
Expand Down