tildebot | Add badword filter to word-based puzzles

The list isn't "complete" in any sense, and it may seem somewhat arbitrary,
but I didn't want to just dump a massive file I found online into it. It
should work perfectly if you want to do that though.
This commit is contained in:
rakiru 2018-07-16 21:59:35 +01:00
parent 58432b5cdf
commit f883cda857
2 changed files with 97 additions and 2 deletions

85
Code/irc/badwords.txt Normal file
View File

@ -0,0 +1,85 @@
Note: This list is probably missing a lot of stuff, but I didn't want to just ram 50 random lists from the internet together. Feel free to replace. - ~deltawitch
== Potentially unwelcome words ==
racist
racists
racism
sexist
sexists
sexism
xenophobe
xenophobia
== Slurs/Insults ==
faggot
faggots
dyke
dykes
chink
chinks
bitch
bitches
bastard
bastards
whore
whores
== Violence/Sexual ==
rape
rapes
raping
rapist
rapists
grope
gropes
semen
bestiality
incest
sadism
domination
sodomy
fingering
pegging
bondage
bareback
humping
sex
sexy
anal
anus
anuses
genitals
vagina
vaginas
clitoris
pussy
pussies
penis
penises
cock
cocks
ass
asses
butt
butts
tit
tits
breast
breasts
cumming
ejaculation
orgasm
orgy
erotic
intercourse
kinky
nipple
nipples
panty
panties
pornography
prostitute
prostitutes
prostitution
rectum
rimming
smut
spunk
undressing

View File

@ -4,9 +4,19 @@ import inflect
p = inflect.engine()
dictionary = "/usr/share/dict/american-english-small"
BAD_WORDS_FILE = "badwords.txt"
def get_wordlist():
# I feel weird calling this "get_wordlist" when it's a generator without calling out that I do in fact realise it's weird - ~deltawitch
with open(BAD_WORDS_FILE, "r") as fp:
bad_words = set(fp)
for word in open(dictionary).readlines():
if "'" not in word and word not in bad_words:
yield word.rstrip()
def get_puzzle():
dict_words = [word.rstrip() for word in open(dictionary).readlines() if "'" not in word]
dict_words = list(get_wordlist())
words = random.sample(dict_words, 3)
key = random.randrange(0,3) #get values 1-3
puzzle = "When alphebetized, what is the " + p.ordinal(p.number_to_words(key+1)) + " in " + ", ".join(words)
@ -15,7 +25,7 @@ def get_puzzle():
return [answer, puzzle]
def get_anagram(maxlen = 6):
dict_words = [word.rstrip() for word in open(dictionary).readlines() if "'" not in word and len(word) > 2 and len(word) <= maxlen+1]
dict_words = [word for word in get_wordlist() if len(word) > 2 and len(word) <= maxlen+1]
word = random.choice(dict_words)
while True:
anagram = ''.join(random.sample(word, len(word)))