@vnbot/toolkitdeprecated

Tool kit to write plugin for ezbot

Usage no npm install needed!

<script type="module">
  import vnbotToolkit from 'https://cdn.skypack.dev/@vnbot/toolkit';
</script>

README

EZBOT-TOOLKIT - WRITE PLUGIN EASIER

How to use ?

  • Install ?
npm i --save @vnbot/toolkit
  • Write plugin ?
const { Plugin, InfoMessage, Joi } = require('@vnbot/toolkit');
const schema = Joi.object({
    prefix: Joi.string().default('!'),
    name: Joi.string().default('Easy Bot'),
    admins: Joi.array().items(Joi.string().required()).default(['100009859624773']),
}).unknown();

const pluginInfo = Plugin.getPluginInfo(__dirname);
module.exports = class CustomBot extends Plugin {
    constructor(options) {
        super(pluginInfo); // plugin config
        const valid = schema.validate(options);
        if (valid.error) throw valid.error;
        this.options = valid.value;
    }
    active(bot) {
        super.active(bot);
        bot.setOptions({
            bot: this.options,
        });
        bot.emit('info', new InfoMessage('Prefix: ' + this.options.prefix));
    }
};
  • Use
const { Bot } = require('@vnbot/ezbot');
const bot = new Bot({
    email: 'email',
    password: 'password',
});

const Plugin = require('PATH_TO_MODULE');
bot.on('info', (msg) => msg && msg.log && msg.log());
bot.once('error', (err) => {
    bot.stop();
});
bot.register(new Plugin({ prefix: '!' }));

bot.start();