mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
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).
This commit is contained in:
parent
0784e2c5be
commit
03e608ffb1
13
run.js
13
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);
|
||||
|
Loading…
Reference in New Issue
Block a user