This package has been deprecated

Author message:

Package no longer supported. Contact support@npmjs.com for more info.

demo-bot-plugin

0.0.6 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i demo-bot-plugin

Weekly Downloads

1

Version

0.0.6

License

MIT

Last publish

Collaborators

  • npm