From 03e608ffb1d5f65f73dd1b6d0f6b1c3a6998ec87 Mon Sep 17 00:00:00 2001 From: Alexander D Brown Date: Thu, 10 Nov 2011 19:36:01 +0000 Subject: [PATCH] Added in a feature to remove underscores ('_') from the ends of nicks. The aim of this feature is display the same messages for users logged in more that once under the same nick (it's common to see 'nick' and 'nick_', etc. for those with bad connections). Of course there are users that won't conform to this, but short of messing around with hostnames it's the best I've got so far (perhaps ~qalias nick=alt_nick could be a future addition to this). --- run.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/run.js b/run.js index 4ae8b67..20b92de 100644 --- a/run.js +++ b/run.js @@ -101,7 +101,7 @@ DBot.prototype.reloadModules = function() { var q = data.message.valMatch(/^~([\d\w\s]*)/, 2); if(q) { q[1] = q[1].trim(); - key = q[1].toLowerCase(); + key = this.cleanNick(q[1]) if(this.db.quoteArrs.hasOwnProperty(key)) { this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random()); } else { @@ -112,4 +112,15 @@ DBot.prototype.reloadModules = function() { }.bind(this)); }; +DBot.prototype.cleanNick = function(key) { + key = key.toLowerCase(); + while(key.endsWith("_")) { + if(this.db.quoteArrs.hasOwnProperty(key)) { + return key; + } + key = key.substring(0, key.length-1); + } + return key; +} + new DBot(modules, timers);