Add zalgo filter in Censor plugin
This commit is contained in:
parent
b3492090b8
commit
395ed8b58d
2 changed files with 129 additions and 0 deletions
117
src/data/Zalgo.ts
Normal file
117
src/data/Zalgo.ts
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
// From https://github.com/b1naryth1ef/rowboat/blob/master/rowboat/util/zalgo.py
|
||||||
|
const zalgoChars = [
|
||||||
|
"\u030d",
|
||||||
|
"\u030e",
|
||||||
|
"\u0304",
|
||||||
|
"\u0305",
|
||||||
|
"\u033f",
|
||||||
|
"\u0311",
|
||||||
|
"\u0306",
|
||||||
|
"\u0310",
|
||||||
|
"\u0352",
|
||||||
|
"\u0357",
|
||||||
|
"\u0351",
|
||||||
|
"\u0307",
|
||||||
|
"\u0308",
|
||||||
|
"\u030a",
|
||||||
|
"\u0342",
|
||||||
|
"\u0343",
|
||||||
|
"\u0344",
|
||||||
|
"\u034a",
|
||||||
|
"\u034b",
|
||||||
|
"\u034c",
|
||||||
|
"\u0303",
|
||||||
|
"\u0302",
|
||||||
|
"\u030c",
|
||||||
|
"\u0350",
|
||||||
|
"\u0300",
|
||||||
|
"\u030b",
|
||||||
|
"\u030f",
|
||||||
|
"\u0312",
|
||||||
|
"\u0313",
|
||||||
|
"\u0314",
|
||||||
|
"\u033d",
|
||||||
|
"\u0309",
|
||||||
|
"\u0363",
|
||||||
|
"\u0364",
|
||||||
|
"\u0365",
|
||||||
|
"\u0366",
|
||||||
|
"\u0367",
|
||||||
|
"\u0368",
|
||||||
|
"\u0369",
|
||||||
|
"\u036a",
|
||||||
|
"\u036b",
|
||||||
|
"\u036c",
|
||||||
|
"\u036d",
|
||||||
|
"\u036e",
|
||||||
|
"\u036f",
|
||||||
|
"\u033e",
|
||||||
|
"\u035b",
|
||||||
|
"\u0346",
|
||||||
|
"\u031a",
|
||||||
|
"\u0315",
|
||||||
|
"\u031b",
|
||||||
|
"\u0340",
|
||||||
|
"\u0341",
|
||||||
|
"\u0358",
|
||||||
|
"\u0321",
|
||||||
|
"\u0322",
|
||||||
|
"\u0327",
|
||||||
|
"\u0328",
|
||||||
|
"\u0334",
|
||||||
|
"\u0335",
|
||||||
|
"\u0336",
|
||||||
|
"\u034f",
|
||||||
|
"\u035c",
|
||||||
|
"\u035d",
|
||||||
|
"\u035e",
|
||||||
|
"\u035f",
|
||||||
|
"\u0360",
|
||||||
|
"\u0362",
|
||||||
|
"\u0338",
|
||||||
|
"\u0337",
|
||||||
|
"\u0361",
|
||||||
|
"\u0489",
|
||||||
|
"\u0316",
|
||||||
|
"\u0317",
|
||||||
|
"\u0318",
|
||||||
|
"\u0319",
|
||||||
|
"\u031c",
|
||||||
|
"\u031d",
|
||||||
|
"\u031e",
|
||||||
|
"\u031f",
|
||||||
|
"\u0320",
|
||||||
|
"\u0324",
|
||||||
|
"\u0325",
|
||||||
|
"\u0326",
|
||||||
|
"\u0329",
|
||||||
|
"\u032a",
|
||||||
|
"\u032b",
|
||||||
|
"\u032c",
|
||||||
|
"\u032d",
|
||||||
|
"\u032e",
|
||||||
|
"\u032f",
|
||||||
|
"\u0330",
|
||||||
|
"\u0331",
|
||||||
|
"\u0332",
|
||||||
|
"\u0333",
|
||||||
|
"\u0339",
|
||||||
|
"\u033a",
|
||||||
|
"\u033b",
|
||||||
|
"\u033c",
|
||||||
|
"\u0345",
|
||||||
|
"\u0347",
|
||||||
|
"\u0348",
|
||||||
|
"\u0349",
|
||||||
|
"\u034d",
|
||||||
|
"\u034e",
|
||||||
|
"\u0353",
|
||||||
|
"\u0354",
|
||||||
|
"\u0355",
|
||||||
|
"\u0356",
|
||||||
|
"\u0359",
|
||||||
|
"\u035a",
|
||||||
|
"\u0323"
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ZalgoRegex = new RegExp(zalgoChars.join("|"));
|
|
@ -4,6 +4,7 @@ import escapeStringRegexp from "escape-string-regexp";
|
||||||
import { GuildLogs } from "../data/GuildLogs";
|
import { GuildLogs } from "../data/GuildLogs";
|
||||||
import { LogType } from "../data/LogType";
|
import { LogType } from "../data/LogType";
|
||||||
import { getInviteCodesInString, getUrlsInString, stripObjectToScalars } from "../utils";
|
import { getInviteCodesInString, getUrlsInString, stripObjectToScalars } from "../utils";
|
||||||
|
import { ZalgoRegex } from "../data/Zalgo";
|
||||||
|
|
||||||
export class CensorPlugin extends Plugin {
|
export class CensorPlugin extends Plugin {
|
||||||
protected serverLogs: GuildLogs;
|
protected serverLogs: GuildLogs;
|
||||||
|
@ -11,6 +12,7 @@ export class CensorPlugin extends Plugin {
|
||||||
getDefaultOptions() {
|
getDefaultOptions() {
|
||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
|
filter_zalgo: false,
|
||||||
filter_invites: false,
|
filter_invites: false,
|
||||||
invite_guild_whitelist: null,
|
invite_guild_whitelist: null,
|
||||||
invite_guild_blacklist: null,
|
invite_guild_blacklist: null,
|
||||||
|
@ -30,6 +32,7 @@ export class CensorPlugin extends Plugin {
|
||||||
{
|
{
|
||||||
level: ">=50",
|
level: ">=50",
|
||||||
config: {
|
config: {
|
||||||
|
filter_zalgo: false,
|
||||||
filter_invites: false,
|
filter_invites: false,
|
||||||
filter_domains: false,
|
filter_domains: false,
|
||||||
blocked_tokens: null,
|
blocked_tokens: null,
|
||||||
|
@ -67,6 +70,15 @@ export class CensorPlugin extends Plugin {
|
||||||
if (msg.type !== 0) return;
|
if (msg.type !== 0) return;
|
||||||
if (!msg.content) return;
|
if (!msg.content) return;
|
||||||
|
|
||||||
|
// Filter zalgo
|
||||||
|
if (this.configValueForMsg(msg, "filter_zalgo")) {
|
||||||
|
const result = ZalgoRegex.exec(msg.content);
|
||||||
|
if (result) {
|
||||||
|
this.censorMessage(msg, `zalgo detected`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Filter invites
|
// Filter invites
|
||||||
if (this.configValueForMsg(msg, "filter_invites")) {
|
if (this.configValueForMsg(msg, "filter_invites")) {
|
||||||
const inviteGuildWhitelist: string[] = this.configValueForMsg(msg, "invite_guild_whitelist");
|
const inviteGuildWhitelist: string[] = this.configValueForMsg(msg, "invite_guild_whitelist");
|
||||||
|
|
Loading…
Add table
Reference in a new issue