0.4.6 • Published 5 years ago

@danroshko/slack-bot v0.4.6

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Slack bot

Slack client library built on top of node-slack-sdk. Provides more high-level interface for building bots with request-reply flow.

Installation

npm i @danroshko/slack-bot

Usage

const token = process.env.SLACK_TOKEN
const Bot = require('slack-bot')
const channel = 'deployments'

const bot = new Bot(token, channel)

bot.on('ping', ctx => {
  ctx.respond('pong')
})

bot.on(/^deploy \w+$/, async ctx => {
  const { user, message } = ctx
  ctx.assert(user.is_admin, 'Permission denied')

  ctx.respond('Doing something...')
  await doSomething(ctx.message.text)
  ctx.respond('Done')
})

bot.onError(err => {
  console.error(err)
})

Context

  • ctx.message - message event
  • ctx.user - user object
  • ctx.channel - limited channel object
  • ctx.respond - function to send back a response
  • ctx.assert - sends back an error message if assertion fails
  • ctx.match - match object
0.4.6

5 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago