Skip to content

simov/slack-incoming-quotes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slack-incoming-quotes

Slack Incoming WebHook with Quotes

Install

npm install -g slack-incoming-quotes

CLI

slack-incoming-quotes \
  --config /path/to/config.json \
  --db /path/to/db.json \
  --quotes /path/to/quotes.json \
  --env environment

config.json

{
  "development": {
    "slack": { "see below" }
  }
}

The username, icon_url and channel keys are optional and take effect only if the hook is a Custom Integration. These 3 keys have no effect for bundled OAuth Apps.

Single hook:

"slack": {
  "hook": "[Hook URL]",
  "username": "[App Name]",
  "icon_url": "[App Avatar]",
  "channel": "[Target #channel or @user]"
}

Multiple hooks with a common username, icon_url and channel configuration:

"slack": {
  "hook": [
    "[Hook URL 1]",
    "[Hook URL 2]"
  ],
  "username": "[App Name]",
  "icon_url": "[App Avatar]",
  "channel": "[Target #channel or @user]"
}

Multiple hooks with separate username, icon_url and channel configuration:

"slack": [
  {
    "hook": "[Hook URL 1]",
    "username": "[App Name]",
    "icon_url": "[App Avatar]",
    "channel": "[Target #channel or @user]"
  },
  {
    "hook": [
      "[Hook URL 2]",
      "[Hook URL 3]"
    ],
    "username": "[App Name]",
    "icon_url": "[App Avatar]",
    "channel": "[Target #channel or @user]"
  }
]

db.json

{
  "development": {
    "index": 0
  },
  "production": {
    "index": 0
  }
}

quotes.json

{
  "quote 1",
  "quote 2",
  "...",
}

Crontab

# Run on every 15 min:
*/15 * * * * node slack-incoming-quotes [params] >> slack-incoming-quotes.log

API

var hook = require('slack-incoming-quotes')

hook({
  config: require('config.json'),
  db: require('db.json'),
  dpath: '/absolute/path/to/db.json',
  quotes: require('quotes.json'),
  env: 'development'
})
.then((responses) => {
  responses.forEach(([res, body]) => {
    console.log(new Date().toString(), res.statusCode, body)
  })
})
.catch((err) => console.error(new Date().toString(), err))

About

Slack Incoming WebHook with Quotes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published