Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
Make banned nicks and keywords case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruoshi.Ling committed Aug 29, 2015
1 parent 29cfffe commit 4d2942e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/irc-to-slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var IrcToSlack = function(config) {
'bannedKeywords': []
});

this.config.bannedIRCNicks = this.config.bannedIRCNicks.join('|').toLowerCase().split('|');
this.config.bannedKeywords = this.config.bannedKeywords.join('|').toLowerCase().split('|');

return this;
};

Expand All @@ -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;
}
}
Expand Down

0 comments on commit 4d2942e

Please sign in to comment.