# behest

> Parser for commands to IRC bots

Latest version **1.0.4** (published 2016-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install behest
pnpm add behest
yarn add behest
bun add behest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2016-02-19 |
| First published | 2014-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Kenan Yildirim |
| Maintainers | kenan |
| Keywords | irc |

## Links

- npm: https://www.npmjs.com/package/behest
- Repository: https://github.com/nwitch/behest
- Homepage: https://github.com/nwitch/behest#readme
- Issues: https://github.com/nwitch/behest/issues
- npm.io page: https://npm.io/package/behest

## Dependencies (2)

- [lodash.foreach](https://npm.io/package/lodash.foreach.md) ^4.1.0
- [lodash.includes](https://npm.io/package/lodash.includes.md) ^4.1.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2016-02-19
- 1.0.3 — 2016-02-19
- 1.0.2 — 2015-05-02
- 1.0.1 — 2015-03-11
- 1.0.0 — 2014-05-20
- 0.0.2 — 2014-03-12
- 0.0.1 — 2014-03-12

## README

# behest

[![Build Status](https://travis-ci.org/nwitch/behest.svg?branch=master)](https://travis-ci.org/nwitch/behest)
[![Dependency Status](https://gemnasium.com/nwitch/behest.svg)](https://gemnasium.com/nwitch/behest)

Parser for commands to IRC bots.

Let's first examine the different syntaxes used by various IRC bots:

```
Classic:                   /help
TwitchTV bots:             !topic
TwitchTV IRC mod commands: .timeout 2 KenanY
#bitcoin-otc:              ;;book MTGUSD
```

Okay, so IRC bot commands typically:

  1. Start with a `!`, `.`, `/`, or two `;`s
  2. Are immediately followed by the command, which is alphanumeric
  3. (optional) Followed by parameter(s), separated by spaces

If a regex was written for this pattern, it would hopefully look like this:

```
/^(([!.\/])|(;{2}))\w+(\s[^\s]+)*$/
```

And if you were to make a railroad diagram of this regex, you would have this:

![trainwreck](https://rawgithub.com/nwitch/behest/master/command.svg)

## Example

``` javascript
var behest = require('behest');

var message = '/give KenanY 5 bitcoins';

behest.isValid(message);
// => true

behest(message);
// => {
// =>   start: '/',
// =>   command: 'give',
// =>   params: ['KenanY', '5', 'bitcoins']
// => }
```

## Installation

``` bash
$ npm install behest
```

## API

### behest(message)

Parses the _String_ `message`. If `message` is not a valid IRC command (the
syntax of which has already been described), an empty _Object_ is returned.
Otherwise, an _Object_ (let's call it `command`) is returned:

  - `command.start` is what began the command (`!`, `/`, `.`, or `;;`)
  - `command.command` is the command (`topic`, `help`, `timeout`, etc.)
  - `command.params` is an _Array_ of what followed the command

### behest.isValid(message)

Returns `true` if `message` passes the command regex. Returns `false` otherwise.

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