diff --git a/command-parse.html b/command-parse.html
new file mode 100644
index 0000000..31b7bd7
--- /dev/null
+++ b/command-parse.html
@@ -0,0 +1,287 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/command-parse.js b/command-parse.js
new file mode 100644
index 0000000..695242c
--- /dev/null
+++ b/command-parse.js
@@ -0,0 +1,65 @@
+
+module.exports = function (RED) {
+ "use strict";
+
+ function ParserEntryPoint(n) {
+ RED.nodes.createNode(this, n);
+ this.property = n.property;
+ this.help_message = n.help_message;
+ this.on("input", msg => {
+ RED.util.evaluateNodeProperty(this.property, "msg", this, msg,
+ (err, value) => {
+ if (err) {
+ this.error(`Can't evaluate msg.${this.property}`);
+ } else {
+ let tokens = value.trim().toLowerCase().split(" ");
+ msg.token_parser = {
+ new_tokens: tokens,
+ consumed_tokens: [],
+ help_message: this.help_message
+ };
+ this.send(msg);
+ };
+ });
+ });
+ }
+
+ RED.nodes.registerType("parser-entry-point", ParserEntryPoint);
+
+ function ConsumaToken(n) {
+ RED.nodes.createNode(this, n);
+ this.rules = n.rules;
+ this.behavior= n.behavior;
+ this.checkall= n.checkall;
+ function check_rule(r, token) {
+ switch(r.t){
+ case "eq":
+ return token == r.v.toLowerCase();
+ case "regex":
+ let reg = new RegExp(r.v);
+ return token.match(reg);
+ }
+ }
+ this.on("input", msg => {
+ let token = msg.token_parser.new_tokens.shift() || "";
+ msg.token_parser.consumed_tokens.push(token);
+ let out = [];
+ let n_matches = 0;
+ for (let r of this.rules) {
+ if(check_rule(r, token)){
+ out.push(msg);
+ n_matches += 1;
+ if (!this.checkall) {
+ break;
+ }
+ } else {
+ out.push(undefined);
+ }
+ }
+ //out.push(n_matches == 0 ? msg : undefined);
+ this.send(out);
+ });
+ }
+ RED.nodes.registerType("parser-consume", ConsumaToken);
+
+}
diff --git a/package.json b/package.json
index c516ef2..3e32aa3 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,8 @@
"node-red" : {
"nodes" : {
"xmpp": "92-xmpp.js",
- "my-debounce": "my-debounce.js"
+ "my-debounce": "my-debounce.js",
+ "command-parse": "command-parse.js"
}
},
"author": {