From aecb9ce2b8f70b188688d90ce39af8b28ec102cb Mon Sep 17 00:00:00 2001 From: "Ruoshi.Ling" Date: Sat, 29 Aug 2015 14:56:28 +0800 Subject: [PATCH] Make banned nicks and keywords case-insensitive --- lib/irc-to-slack.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/irc-to-slack.js b/lib/irc-to-slack.js index 7a31a73..535a2a9 100644 --- a/lib/irc-to-slack.js +++ b/lib/irc-to-slack.js @@ -14,6 +14,9 @@ var IrcToSlack = function(config) { 'bannedKeywords': [] }); + this.config.bannedIRCNicks.join('|').toLowerCase().split('|'); + this.config.bannedKeywords.join('|').toLowerCase().split('|'); + return this; }; @@ -32,12 +35,12 @@ IrcToSlack.prototype._sentToSlack = function(type, from, to, message) { var isNickExist = !!this.nameMap.getSlackNameByIrcNick(from); var bannedKeywords = this.config.bannedKeywords; - if (_.contains(this.config.bannedIRCNicks, username)) { + if (_.contains(this.config.bannedIRCNicks, username.toLowerCase())) { return; } for (var i=0, len=bannedKeywords.length; i < len; i++) { - if (message.toLowerCase().indexOf(bannedKeywords[i].toLowerCase()) > -1) { + if (message.toLowerCase().indexOf(bannedKeywords[i]) > -1) { return; } }