Chatcommand Parser
A package to parse commands in text chats (IRC, Slack, ...)
Installation
npm install chatcommand-parser
Usage
Creating commands
var parser = ; var p = "!"; //You can optionally pass a prefix string to prefix every command with, defaults to "!"p;p;p; //Add argumentsp"test2"; //Add an int type argument named 'integer'p"test2"; // Defaults to the 'word' type argument - gets everything up to a space p"test3"
Parsing commands
var parsed = p;if !parsed return; //Returns null if no matching command foundif parsedcommand == "test" //If, for example, text == "!test" //Matched the 'test' commandif parsedcommand == "test2" //text == "!test2 2 test" //Get the argument values console; //Prints '2' console; //Prints 'test'