mirror of https://github.com/calzoneman/sync.git
Add initial channel setting for new account chat delay
This commit is contained in:
parent
701d470494
commit
8305c235eb
|
@ -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) {
|
ChatModule.prototype.handleChatMsg = function (user, data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
counters.add("chat:incoming");
|
counters.add("chat:incoming");
|
||||||
|
@ -132,17 +154,8 @@ ChatModule.prototype.handleChatMsg = function (user, data) {
|
||||||
// Limit to 240 characters
|
// Limit to 240 characters
|
||||||
data.msg = data.msg.substring(0, 240);
|
data.msg = data.msg.substring(0, 240);
|
||||||
|
|
||||||
const firstSeen = user.getFirstSeenTime();
|
// Restrict new accounts/IPs from chatting and posting links
|
||||||
// TODO: configurable times
|
if (this.restrictNewAccount(user, data)) {
|
||||||
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"
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +202,11 @@ ChatModule.prototype.handlePm = function (user, data) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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"))) {
|
if (data.msg.match(Config.get("link-domain-blacklist-regex"))) {
|
||||||
this.channel.logger.log(user.displayip + " (" + user.getName() + ") was kicked for " +
|
this.channel.logger.log(user.displayip + " (" + user.getName() + ") was kicked for " +
|
||||||
"blacklisted domain");
|
"blacklisted domain");
|
||||||
|
|
|
@ -25,7 +25,9 @@ function OptionsModule(channel) {
|
||||||
allow_dupes: false, // Allow duplicate videos on the playlist
|
allow_dupes: false, // Allow duplicate videos on the playlist
|
||||||
torbanned: false, // Block connections from Tor exit nodes
|
torbanned: false, // Block connections from Tor exit nodes
|
||||||
allow_ascii_control: false,// Allow ASCII control characters (\x00-\x1f)
|
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.channel.logger.log("[mod] " + user.getName() + " updated channel options");
|
||||||
this.sendOpts(this.channel.users);
|
this.sendOpts(this.channel.users);
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,6 +46,15 @@ mixin textbox-auto(id, label, placeholder)
|
||||||
else
|
else
|
||||||
input.form-control.cs-textbox(id=id, type="text")
|
input.form-control.cs-textbox(id=id, type="text")
|
||||||
|
|
||||||
|
mixin textbox-timeinput-auto(id, label, placeholder)
|
||||||
|
.form-group
|
||||||
|
label.control-label.col-sm-4(for=id)= label
|
||||||
|
.col-sm-8
|
||||||
|
if placeholder
|
||||||
|
input.form-control.cs-textbox-timeinput(id=id, type="text", placeholder=placeholder)
|
||||||
|
else
|
||||||
|
input.form-control.cs-textbox-timeinput(id=id, type="text")
|
||||||
|
|
||||||
mixin miscoptions
|
mixin miscoptions
|
||||||
#cs-miscoptions.tab-pane.active
|
#cs-miscoptions.tab-pane.active
|
||||||
h4 General Settings
|
h4 General Settings
|
||||||
|
@ -63,6 +72,11 @@ mixin miscoptions
|
||||||
+rcheckbox-auto("cs-chat_antiflood", "Throttle chat")
|
+rcheckbox-auto("cs-chat_antiflood", "Throttle chat")
|
||||||
+textbox-auto("cs-chat_antiflood_burst", "# of messages allowed before throttling")
|
+textbox-auto("cs-chat_antiflood_burst", "# of messages allowed before throttling")
|
||||||
+textbox-auto("cs-chat_antiflood_sustained", "# of messages (after burst) allowed per second")
|
+textbox-auto("cs-chat_antiflood_sustained", "# of messages (after burst) allowed per second")
|
||||||
|
+textbox-timeinput-auto("cs-new_user_chat_delay", "Delay before new accounts can chat", "0")
|
||||||
|
.form-group
|
||||||
|
.col-sm-8.col-sm-offset-4
|
||||||
|
span.text-info Restrictions to new accounts can be disabled by setting the delay to 0.
|
||||||
|
+textbox-timeinput-auto("cs-new_user_chat_link_delay", "Delay before new accounts can post links in chat", "0")
|
||||||
.form-group
|
.form-group
|
||||||
.col-sm-8.col-sm-offset-4
|
.col-sm-8.col-sm-offset-4
|
||||||
span.text-info Changes are automatically saved.
|
span.text-info Changes are automatically saved.
|
||||||
|
|
|
@ -930,6 +930,8 @@ function handleModPermissions() {
|
||||||
$("#cs-torbanned").prop("checked", CHANNEL.opts.torbanned);
|
$("#cs-torbanned").prop("checked", CHANNEL.opts.torbanned);
|
||||||
$("#cs-allow_ascii_control").prop("checked", CHANNEL.opts.allow_ascii_control);
|
$("#cs-allow_ascii_control").prop("checked", CHANNEL.opts.allow_ascii_control);
|
||||||
$("#cs-playlist_max_per_user").val(CHANNEL.opts.playlist_max_per_user || 0);
|
$("#cs-playlist_max_per_user").val(CHANNEL.opts.playlist_max_per_user || 0);
|
||||||
|
$("#cs-new_user_chat_delay").val(CHANNEL.opts.new_user_chat_delay || 0);
|
||||||
|
$("#cs-new_user_chat_link_delay").val(CHANNEL.opts.new_user_chat_link_delay || 0);
|
||||||
(function() {
|
(function() {
|
||||||
if(typeof CHANNEL.opts.maxlength != "number") {
|
if(typeof CHANNEL.opts.maxlength != "number") {
|
||||||
$("#cs-maxlength").val("");
|
$("#cs-maxlength").val("");
|
||||||
|
|
Loading…
Reference in New Issue