Add initial channel setting for new account chat delay
This commit is contained in:
parent
701d470494
commit
8305c235eb
4 changed files with 63 additions and 13 deletions
|
|
@ -121,6 +121,28 @@ ChatModule.prototype.shadowMutedUsers = function () {
|
|||
});
|
||||
};
|
||||
|
||||
ChatModule.prototype.restrictNewAccount = function restrictNewAccount(user, data) {
|
||||
if (user.account.effectiveRank < 2 && this.channel.modules.options) {
|
||||
const firstSeen = user.getFirstSeenTime();
|
||||
const opts = this.channel.modules.options;
|
||||
// TODO: configurable times
|
||||
if (firstSeen > Date.now() - opts.get("new_user_chat_delay")) {
|
||||
user.socket.emit("spamFiltered", {
|
||||
reason: "NEW_USER_CHAT"
|
||||
});
|
||||
return true;
|
||||
} else if ((firstSeen > Date.now() - opts.get("new_user_chat_link_delay"))
|
||||
&& data.msg.match(LINK)) {
|
||||
user.socket.emit("spamFiltered", {
|
||||
reason: "NEW_USER_CHAT_LINK"
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleChatMsg = function (user, data) {
|
||||
var self = this;
|
||||
counters.add("chat:incoming");
|
||||
|
|
@ -132,17 +154,8 @@ ChatModule.prototype.handleChatMsg = function (user, data) {
|
|||
// Limit to 240 characters
|
||||
data.msg = data.msg.substring(0, 240);
|
||||
|
||||
const firstSeen = user.getFirstSeenTime();
|
||||
// TODO: configurable times
|
||||
if (firstSeen > Date.now() - 5 * 60 * 1000) {
|
||||
user.socket.emit("spamFiltered", {
|
||||
reason: "NEW_USER_CHAT"
|
||||
});
|
||||
return;
|
||||
} else if ((firstSeen > Date.now() - 24 * 60 * 60 * 1000) && data.msg.match(LINK)) {
|
||||
user.socket.emit("spamFiltered", {
|
||||
reason: "NEW_USER_CHAT_LINK"
|
||||
});
|
||||
// Restrict new accounts/IPs from chatting and posting links
|
||||
if (this.restrictNewAccount(user, data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -188,6 +201,11 @@ ChatModule.prototype.handlePm = function (user, data) {
|
|||
msg: "You must be signed in to send PMs"
|
||||
});
|
||||
}
|
||||
|
||||
// Restrict new accounts/IPs from chatting and posting links
|
||||
if (this.restrictNewAccount(user, data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.msg.match(Config.get("link-domain-blacklist-regex"))) {
|
||||
this.channel.logger.log(user.displayip + " (" + user.getName() + ") was kicked for " +
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ function OptionsModule(channel) {
|
|||
allow_dupes: false, // Allow duplicate videos on the playlist
|
||||
torbanned: false, // Block connections from Tor exit nodes
|
||||
allow_ascii_control: false,// Allow ASCII control characters (\x00-\x1f)
|
||||
playlist_max_per_user: 0 // Maximum number of playlist items per user
|
||||
playlist_max_per_user: 0, // Maximum number of playlist items per user
|
||||
new_user_chat_delay: 10 * 60 * 1000, // Minimum account/IP age to chat
|
||||
new_user_chat_link_delay: 60 * 60 * 1000 // Minimum account/IP age to post links
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -271,6 +273,20 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
}
|
||||
}
|
||||
|
||||
if ("new_user_chat_delay" in data) {
|
||||
var delay = parseInt(data.new_user_chat_delay);
|
||||
if (!isNaN(delay) && delay >= 0) {
|
||||
this.opts.new_user_chat_delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
if ("new_user_chat_link_delay" in data) {
|
||||
var delay = parseInt(data.new_user_chat_link_delay);
|
||||
if (!isNaN(delay) && delay >= 0) {
|
||||
this.opts.new_user_chat_link_delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
this.channel.logger.log("[mod] " + user.getName() + " updated channel options");
|
||||
this.sendOpts(this.channel.users);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue