1.0.0 • Published 7 years ago

botkit-helper v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

botkit-helper

Quick-connect to Slack kit for botkit.

Setup

  npm install --save botkit-helper
  npm config set <your-bot-name>:slacktoken <your-slack-api-taken>
  npm config set <your-bot-name>:mongouri <mongodb://localhost:27018/your-db>

NB. Because NPM config keys are used, your bot must be instantiated through an npm script to run, such as npm start or npm run bot - and in this instance, <your-bot-name> is the name of your NPM package. For example, for the following sample package.json:

{
  "name": "holt",
  ...
  "dependencies": {
    "botkit-helper": "^1.0.0"
  }
}

run using npm config set holt:mongouri <mongodb://localhost:27018/your-db>

Usage

  const bothelper = require('botkit-helper');

botkit-helper exposes references directly to botkit's bot and controller, as well as some useful helper features:

  • bothelper.srcchannel

    A list of methods your bot can listen to:

  • DM - direct message only

  • AT - any mention of your bot, eg. @mybot
  • ANY - whether in a direct message or when in a channel and the bot is mentioned

    bothelper.controller.hears(['hi'], bothelper.src.ANY, (bot, message) => { }

  • bothelper.getSlackUsername(userId)

    A method to find the username of the user referenced.

    bothelper.bot.say(bothelper.getSlackUsername(message.user));