0.0.6 • Published 7 years ago

demo-bot-plugin v0.0.6

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

demo-bot-plugin Build Status XO code style

Demo Bot Core Plugin functionality

Install

$ npm install --save demo-bot-plugin

Usage

const Plugin = require('demo-bot-plugin');

// create plugin

const plugin = new Plugin({
	name: 'test',
	questions: [{
			type: 'list',
			name: 'theme',
			message: 'What do you want to do?',
			choices: [
				'Order a pizza',
				'Make a reservation'
			]
	}],
	handler: (answers) => {
		console.log(answers);
	}
})

// run plugin

plugin.run();

API

Plugin(config)

Returns a Plugin instance.

config

name

Type: string Required: true

Plugin nameentifier.

questions

Type: object[] Default: []

Questions to be prompted (Inquerier Questions)

handler

Type: Function Default: answers => {}

Handler that gets called with answers after user answers questions.

before

Type: Function Default: () => {}

Hook that gets called before. Makes it possible to perform any actions before questions, handler or run is called.

const plugin = new Plugin({
	name: 'test',
	questions: [{
			type: 'list',
			name: 'theme',
			message: 'What do you want to do?',
			choices: [
				'Order a pizza',
				'Make a reservation'
			]
	}],
	before: () => {
		// remove question
		this.questions.pop();
	},
	handler: answers => {
		console.log(answers);
	}
})

Related

License

MIT © Jonathan Doherty

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.1

7 years ago