mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
feat: server chat filter for slurs and sexual talk, no secret valentines
- lib/chatfilter.js reads its rules from lib/chat-filter.txt (reloaded when it changes) and applies them to typed chat, jam-a-gram messages and jammer wall posts. players cannot turn it off. a blocked message reaches nobody, its sender sees the game's "inappropriate behavior" warning, and blocked chat is kept in the chat log marked not sent. - rules match words, prefixes and phrases, in order or anywhere, with "?" for any word and "!" for exceptions, and see through stand-in letters, drawn-out letters and spaced-out spelling. the example rules block sexual talk aimed at someone while letting plain swearing through; the slur section is left for the owner to fill in. - secret valentine jam-a-grams are off: the client sends a normal card without asking (buildVersion 56), and the server refuses a card asked for as a secret valentine.
This commit is contained in:
1 parent
aa455f52d0
commit
89fe4d2a28
8 files changed
+291
-6
No files matched your search
+12
-2
@@ -4,6 +4,7 @@ const crypto = require("crypto");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const accounts = require("./accounts.js");
|
||||
const chatFilter = require("./chatfilter.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
const limits = require("./limits.js");
|
||||
const {isUint} = require("./player.js");
|
||||
@@ -72,7 +73,7 @@ const flat = value => scalar(value) || (typeof value === "object" && !Array.isAr
|
||||
const plainParam = value => flat(value) || (Array.isArray(value) && value.length <= MAX_PARAM_ENTRIES && value.every(flat));
|
||||
const whole = value => (Number.isInteger(Number(value)) ? Number(value) : 0);
|
||||
|
||||
module.exports = ({blocks}) => {
|
||||
module.exports = ({blocks, findOnline}) => {
|
||||
const tokens = new Map(); // token -> {viewer: account id, owner: account id, expires}
|
||||
|
||||
const mayOpen = (owner, viewer) => {
|
||||
@@ -150,7 +151,16 @@ module.exports = ({blocks}) => {
|
||||
const put = (owner, viewer, body) => {
|
||||
const colours = Array.isArray(body.ac) ? body.ac.slice(0, 3).map(String) : [];
|
||||
const message = clean(body.m === undefined ? "" : body.m);
|
||||
if (!message || isSilenced(viewer) || !colours.every(isUint) || !postsPerTenMinutes.allow(viewer.id)) {
|
||||
// the server's filter (lib/chatfilter.js) too.
|
||||
const rule = message ? chatFilter.broken(message) : null;
|
||||
if (rule) {
|
||||
console.log(`[filter] ${viewer.username} on ${owner.username}'s wall: "${message}" (${rule})`);
|
||||
const session = findOnline(viewer.username);
|
||||
if (session) {
|
||||
chatFilter.warn(session);
|
||||
}
|
||||
}
|
||||
if (!message || rule || isSilenced(viewer) || !colours.every(isUint) || !postsPerTenMinutes.allow(viewer.id)) {
|
||||
// PlayerWallGui.onMessageSent: cs -1 = "could not be posted"
|
||||
return {PUT: {s: false, cs: -1}};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user