# @vnbot/toolkit

> Tool kit to write plugin for ezbot

Latest version **1.0.4** (published 2021-02-17) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @vnbot/toolkit
pnpm add @vnbot/toolkit
yarn add @vnbot/toolkit
bun add @vnbot/toolkit
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-02-17 |
| First published | 2021-02-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | notekunn |
| Keywords | ezbot, vnbot, facebook, messenger, plugin |

## Links

- npm: https://www.npmjs.com/package/@vnbot/toolkit
- Repository: https://github.com/VNBot-Developers/ezbot-toolkit
- Homepage: https://github.com/VNBot-Developers/ezbot-toolkit#readme
- Issues: https://github.com/VNBot-Developers/ezbot-toolkit/issues
- npm.io page: https://npm.io/package/@vnbot/toolkit

## Dependencies (1)

- [joi](https://npm.io/package/joi.md) ^17.4.0

## Recent versions

- 1.0.4 (latest) — 2021-02-17
- 1.0.3 — 2021-02-17
- 1.0.2 — 2021-02-17
- 1.0.1 — 2021-02-17
- 1.0.0 — 2021-02-17

## README

### EZBOT-TOOLKIT - WRITE PLUGIN EASIER

#### How to use ?

-   Install ?

```bash
npm i --save @vnbot/toolkit
```

-   Write plugin ?

```javascript
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

```javascript
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();
```

---
_Source: https://npm.io/package/@vnbot/toolkit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
