From 309e5d8b463699b4398788d86a2379c9741a4341 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 13 Sep 2014 00:01:54 -0500 Subject: [PATCH] Doing it live --- config.template.yaml | 2 ++ lib/channel/chat.js | 10 ++++++++++ lib/config.js | 11 ++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/config.template.yaml b/config.template.yaml index 64afd7a3..6d492f81 100644 --- a/config.template.yaml +++ b/config.template.yaml @@ -183,3 +183,5 @@ channel-blacklist: [] # * ffmpeg must be installed on the server ffmpeg: enabled: false + +link-domain-blacklist: [] diff --git a/lib/channel/chat.js b/lib/channel/chat.js index 43cf1408..57f839e0 100644 --- a/lib/channel/chat.js +++ b/lib/channel/chat.js @@ -1,3 +1,4 @@ +var Config = require("../config"); var User = require("../user"); var XSS = require("../xss"); var ChannelModule = require("./module"); @@ -215,6 +216,15 @@ ChatModule.prototype.handlePm = function (user, data) { }; ChatModule.prototype.processChatMsg = function (user, data) { + if (data.msg.match(Config.get("link-domain-blacklist-regex"))) { + this.channel.logger.log(user.displayip + " (" + user.getName() + ") was kicked for " + + "blacklisted domain"); + user.kick(); + this.sendModMessage(user.getName() + " was kicked: blacklisted domain in " + + "chat message", 2); + return; + } + if (data.msg.indexOf("/afk") === -1) { user.setAFK(false); } diff --git a/lib/config.js b/lib/config.js index d489c302..cdd300c5 100644 --- a/lib/config.js +++ b/lib/config.js @@ -105,7 +105,8 @@ var defaults = { "channel-blacklist": [], ffmpeg: { enabled: false - } + }, + "link-domain-blacklist": [] }; /** @@ -333,6 +334,14 @@ function preprocessConfig(cfg) { }); cfg["channel-blacklist"] = tbl; + if (cfg["link-domain-blacklist"].length > 0) { + cfg["link-domain-blacklist-regex"] = new RegExp( + cfg["link-domain-blacklist"].join("|").replace(/\./g, "\\."), "gi"); + } else { + // Match nothing + cfg["link-domain-blacklist-regex"] = new RegExp("$^", "gi"); + } + return cfg; }