Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

behest

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

behest

Parser for commands to IRC bots

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

behest

Build Status Dependency Status

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

Example

var behest = require('behest');

var message = '/give KenanY 5 bitcoins';

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

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

Installation

$ 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.

Keywords

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc