Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.
/ knit Public archive

[UNMAINTAINED] A Slack bot library, built as an abstraction on top of Botkit

License

Notifications You must be signed in to change notification settings

rowanmanning/knit

Repository files navigation

Knit

Knit is an abstraction on top of Botkit which I've pretty much just built for one bot for myself. You're free to use, but it might not get the best level of support and it has only been tested with Slack

⚠️ NOTE: This project is no longer being maintained. If you're interested in taking over maintenance, please contact me.

NPM version Node.js version support Build status MIT licensed

const bot = new Bot({
	name: 'ExampleBot',
	slackToken: 'xxxx-xxx-xxxx'
});

bot.use(new Bot.Listener.Ambient({
	name: 'example listener',
	trigger: /i'?m hungry/i,
	handler: new Bot.Responder.Message({
		message: `Hello hungry, I'm ${bot.name}`
	})
}));

bot.connect();

Table of Contents

Requirements

Knit requires the following to run:

Usage

This usage guide covers the basics of using Knit. The full API documentation is available here.

Install Knit with npm:

npm install @rowanmanning/knit

Include Knit in your code:

const Bot = require('@rowanmanning/knit');

Create and run a bot:

const bot = new Bot({
	name: 'ExampleBot',
	slackToken: 'xxxx-xxx-xxxx'
});

bot.connect();

Create a listener which responds with a canned message:

// Register a bot listener which listens for a trigger phrase
// and then responds with a standard response
bot.use(new Bot.Listener.Ambient({

	// The name of the listener, used in logging mostly
	name: 'hunger listener',

	// The trigger phrase to listen for. This can be a string,
	// regular expression, or an array of triggers
	trigger: /i'?m hungry/i,

	// The handler can be either a bot responder, or a function.
	// Here, we're using a standard message responder
	handler: new Bot.Responder.Message({
		message: `Hello hungry, I'm ${bot.name}`
	})

}));

API Documentation

You can find the full API Documentation here.

Examples

There are several examples in the example directory. You can run these providing a SLACK_TOKEN environment variable to see them in action.

Contributing

To contribute to Knit, clone this repo locally and commit your code on a separate branch. Please write unit tests for your code, and run the linter before opening a pull-request:

make test    # run all tests
make verify  # run all linters

License

Knit is licensed under the MIT license.
Copyright © 2017, Rowan Manning

About

[UNMAINTAINED] A Slack bot library, built as an abstraction on top of Botkit

Resources

License

Stars

Watchers

Forks

Packages

No packages published