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

Commit 4d2942e

Browse files
author
Ruoshi.Ling
committed
Make banned nicks and keywords case-insensitive
1 parent 29cfffe commit 4d2942e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/irc-to-slack.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ var IrcToSlack = function(config) {
1414
'bannedKeywords': []
1515
});
1616

17+
this.config.bannedIRCNicks = this.config.bannedIRCNicks.join('|').toLowerCase().split('|');
18+
this.config.bannedKeywords = this.config.bannedKeywords.join('|').toLowerCase().split('|');
19+
1720
return this;
1821
};
1922

@@ -32,12 +35,12 @@ IrcToSlack.prototype._sentToSlack = function(type, from, to, message) {
3235
var isNickExist = !!this.nameMap.getSlackNameByIrcNick(from);
3336
var bannedKeywords = this.config.bannedKeywords;
3437

35-
if (_.contains(this.config.bannedIRCNicks, username)) {
38+
if (_.contains(this.config.bannedIRCNicks, username.toLowerCase())) {
3639
return;
3740
}
3841

3942
for (var i=0, len=bannedKeywords.length; i < len; i++) {
40-
if (message.toLowerCase().indexOf(bannedKeywords[i].toLowerCase()) > -1) {
43+
if (message.toLowerCase().indexOf(bannedKeywords[i]) > -1) {
4144
return;
4245
}
4346
}

0 commit comments

Comments
 (0)