ZeldaFan0225 / AI_Horde_Discord

A discord bot to interact with https://aihorde.net
GNU Affero General Public License v3.0
48 stars 14 forks source link

Feature request: allow blacklist to be a regex #42

Closed Efreak closed 1 year ago

Efreak commented 1 year ago

I'd like to blacklist certain words without it mattering whether or not they're using exact case or doubling letters or adding accents. The easiest way to do this is to allow regexes in the blacklist. I've implemented this like so:

if(ctx.client.config.advanced_generate?.blacklisted_regexes?.some(w => new RegExp(w,'i').test(prompt.normalize("NFD").replace(/[\u0300-\u036f]/g, "")))) return ctx.error({error: "Your prompt included one or more blacklisted words"})

I tried adding the regex directly in the config, but couldn't figure out how to add a regex in the schema in types.ts (stuff I found online didn't work), but this also just seems easier.

This can also control if certain words are only allowed in positive or negative prompt: "sad.?###|###.?happy" to disallow sad images.

ZeldaFan0225 commented 1 year ago

the input of slash commands is already kinda normalized,

image

it already gives it as plaintext or rather handles it as plaintext

ZeldaFan0225 commented 1 year ago

this has been implemented