From 1e089bf972b9a2934b36feee13aaaa662023f2ee Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Tue, 18 Dec 2012 17:17:20 +0100 Subject: [PATCH] removing duplicate regexp --- lib/ns_client.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ns_client.js b/lib/ns_client.js index 9ba126e..125d859 100644 --- a/lib/ns_client.js +++ b/lib/ns_client.js @@ -32,16 +32,19 @@ var NsClient = function() { })(this); this.actions.msg = {}; - this.actions.msg.is = function(msg) { - var exp = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| msg ([^ ]*)/; - return exp.exec(msg) !== null; - }; + this.actions.msg.exp = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| msg ([^ ]*)/; + this.actions.msg.is = (function(exp) { + return function(msg) { + console.log(exp); + return exp.exec(msg) !== null; + }; + })(this.actions.msg.exp); this.actions.msg.act = (function(elem) { return function(msg) { if ($cs.opts.get("enable_msg")) { - var mo = {}, exp = /user_cmd (\d+):user:.*?:(.*?)@(.*?):.*?:(.*?):(.*?) \| msg ([^ ]*)/; + var mo = {}; - mch = exp.exec(msg); + mch = elem.actions.msg.exp.exec(msg); if (mch !== null && typeof elem.msgHandler !== "undefined") { mo.socket = mch[1]; mo.login = mch[2];