mirror of
https://github.com/polyjitter/searchbot-discord.git
synced 2024-08-14 22:46:55 +00:00
Performance improvements, regex filtering
This commit is contained in:
parent
cc257ca0d6
commit
0d12b1849f
3 changed files with 178 additions and 40 deletions
156
extensions/models/regex.py
Normal file
156
extensions/models/regex.py
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
# WARNING This list includes slurs.
|
||||||
|
|
||||||
|
from re import compile, I, X
|
||||||
|
|
||||||
|
nono_re = compile(
|
||||||
|
r"""tranny|
|
||||||
|
faggot|
|
||||||
|
fag\b|
|
||||||
|
\bporn|
|
||||||
|
\bcock\b|
|
||||||
|
dick|
|
||||||
|
t\s*i\s*t\s*t\s*y|
|
||||||
|
\bt\s*i\s*t\b|
|
||||||
|
\bb\s*o\s*o\s*b|
|
||||||
|
p\s*e\s*n\s*i\s*s|
|
||||||
|
s\s*l\s*u\s*t|
|
||||||
|
\bc\s*u\s*m\b|
|
||||||
|
\bj\s*i\s*z\s*z|
|
||||||
|
\bsemen\b|
|
||||||
|
[cg]ooch|
|
||||||
|
pussy|
|
||||||
|
penis|
|
||||||
|
fetish|
|
||||||
|
bdsm|
|
||||||
|
sexy|
|
||||||
|
xxx|
|
||||||
|
orgasm|
|
||||||
|
masturbat|
|
||||||
|
erotic|
|
||||||
|
creampie|
|
||||||
|
fap|
|
||||||
|
\bnude\b|
|
||||||
|
orgasm|
|
||||||
|
squirting|
|
||||||
|
y\s*i\s*f\s*f|
|
||||||
|
e\s*6\s*2\s*1|
|
||||||
|
\bsex|
|
||||||
|
ejaculat|
|
||||||
|
cunt| # scunthorpe
|
||||||
|
vagina|
|
||||||
|
coom|
|
||||||
|
troon|
|
||||||
|
h\s*e\s*n\s*t\s*a\s*i|
|
||||||
|
yaoi|
|
||||||
|
bukkake|
|
||||||
|
bara\b|
|
||||||
|
shota|
|
||||||
|
loli|
|
||||||
|
toddlercon|
|
||||||
|
fetish|
|
||||||
|
spunk|
|
||||||
|
pron|
|
||||||
|
p0rn|
|
||||||
|
pr0n|
|
||||||
|
gloryhole|
|
||||||
|
felch|
|
||||||
|
(skull|goat|dog)fuck|
|
||||||
|
\bscat\b|
|
||||||
|
piss\s*(play)?|
|
||||||
|
underage|
|
||||||
|
bbw|
|
||||||
|
fisting|
|
||||||
|
queef|
|
||||||
|
rimming|
|
||||||
|
rimjob|
|
||||||
|
bdsm|
|
||||||
|
cbt|
|
||||||
|
blumpkin|
|
||||||
|
boner|
|
||||||
|
prostitut|
|
||||||
|
butt\s*plug|
|
||||||
|
transvestite|
|
||||||
|
femboy|
|
||||||
|
castrat|
|
||||||
|
philia|
|
||||||
|
edging|
|
||||||
|
edgeplay|
|
||||||
|
enema|
|
||||||
|
facial|
|
||||||
|
fellat|
|
||||||
|
femdom|
|
||||||
|
(foot|blow|tit|hand)job|
|
||||||
|
frot|
|
||||||
|
gang\s*bang|
|
||||||
|
glory\s*hole|
|
||||||
|
hermap|
|
||||||
|
(jerk|jack)(ing)?\s*off|
|
||||||
|
kink|
|
||||||
|
wet\s*dream|
|
||||||
|
\banal\b| # banal, analyze
|
||||||
|
pegging|
|
||||||
|
pre(-?|\s*)cum|
|
||||||
|
priap|
|
||||||
|
scrotum|
|
||||||
|
shemale|
|
||||||
|
smegma|
|
||||||
|
smut|
|
||||||
|
softcore|
|
||||||
|
transs?exual|
|
||||||
|
voyeur|
|
||||||
|
viagra|
|
||||||
|
wank|
|
||||||
|
whore|
|
||||||
|
\bnigger| # not snigger
|
||||||
|
nignog|
|
||||||
|
watersports|
|
||||||
|
vietnamese\s*landmine|
|
||||||
|
dirty\s*sanchez|
|
||||||
|
\bass\b|
|
||||||
|
\bsh[ia]t\b|
|
||||||
|
\bpoo\b|
|
||||||
|
\brape\b|
|
||||||
|
\bjap\b|
|
||||||
|
\bspic\b|
|
||||||
|
chink|
|
||||||
|
retard|
|
||||||
|
\btard\b|
|
||||||
|
bitch|
|
||||||
|
\barse\b|
|
||||||
|
\banus\b|
|
||||||
|
blue\s*waffle|
|
||||||
|
tubgirl|
|
||||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
|
\bs\s*m\s*e\s*g\s*m\s*a\b|
|
||||||
|
\d{6}""",
|
||||||
|
I | X
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
pass
|
|
@ -14,6 +14,7 @@ import re
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from extensions.models import SearchExceptions
|
from extensions.models import SearchExceptions
|
||||||
|
from extensions.models.regex import nono_re
|
||||||
|
|
||||||
|
|
||||||
class Search(commands.Cog, name="Basic"):
|
class Search(commands.Cog, name="Basic"):
|
||||||
|
@ -47,31 +48,7 @@ class Search(commands.Cog, name="Basic"):
|
||||||
safesearch: str
|
safesearch: str
|
||||||
|
|
||||||
# NSFW Filtering
|
# NSFW Filtering
|
||||||
# WARNING This list includes slurs.
|
if nono_re.match(query):
|
||||||
nono_words = [
|
|
||||||
'tranny', 'faggot', 'fag', 'porn', 'cock', 'dick',
|
|
||||||
'titty', ' tit ', 'boob', 'penis', 'slut', ' cum ', 'jizz',
|
|
||||||
'semen', 'cooch', 'coochie', 'pussy', 'penis', 'fetish',
|
|
||||||
'bdsm', 'sexy', 'xxx', 'orgasm', 'masturbat',
|
|
||||||
'erotic', 'creampie', 'fap', 'nude', 'orgasm',
|
|
||||||
'squirting', 'yiff', 'e621', ' sex', 'ejaculat',
|
|
||||||
'cunt', 'vagina', 'coom', 'troon', 'hentai', 'yaoi',
|
|
||||||
'bukkake', 'bara', 'shota', 'loli', 'fetish', 'spunk',
|
|
||||||
'pron', 'p0rn', 'pr0n', 'gloryhole', 'felch', 'skullfuck',
|
|
||||||
'scat', 'pissplay', 'piss play', 'underage', 'bbw',
|
|
||||||
'fisting', 'queef', "rimming", 'rimjob', 'bdsm',
|
|
||||||
'cbt', 'blumpkin', 'boner', 'prostitut', 'butt plug',
|
|
||||||
'transvestite', 'femboy', 'castrat', 'philia', 'edging',
|
|
||||||
'edgeplay', 'enema', 'facial', 'fellat', 'femdom', 'footjob',
|
|
||||||
'blowjob', 'titjob', 'handjob', 'frot', 'gang bang', 'gangbang',
|
|
||||||
'glory hole', 'hermap', 'jerk off', 'jerking off', 'jack off',
|
|
||||||
'jacking off', 'kink', 'wet dream', 'anal', 'pegging', 'precum',
|
|
||||||
'pre-cum', 'pre cum', 'priap', 'scrotum', 'shemale', 'smegma',
|
|
||||||
'smut', 'softcore', 'transsexual', 'voyeur', 'viagra', 'wank',
|
|
||||||
'whore'
|
|
||||||
]
|
|
||||||
|
|
||||||
if any(n in query for n in nono_words):
|
|
||||||
raise SearchExceptions.SafesearchFail('Query had NSFW.')
|
raise SearchExceptions.SafesearchFail('Query had NSFW.')
|
||||||
|
|
||||||
base = "https://api.qwant.com/api"
|
base = "https://api.qwant.com/api"
|
||||||
|
|
7
main.py
7
main.py
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
'''Main File'''
|
'''Main File'''
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -163,6 +164,7 @@ class Bot(commands.Bot):
|
||||||
|
|
||||||
# Maintenance Mode
|
# Maintenance Mode
|
||||||
if self.maintenance:
|
if self.maintenance:
|
||||||
|
async def presence_task():
|
||||||
await self.change_presence(
|
await self.change_presence(
|
||||||
activity=discord.Activity(
|
activity=discord.Activity(
|
||||||
name="Maintenance",
|
name="Maintenance",
|
||||||
|
@ -171,6 +173,7 @@ class Bot(commands.Bot):
|
||||||
status=discord.Status.dnd
|
status=discord.Status.dnd
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
async def presence_task():
|
||||||
await self.change_presence(
|
await self.change_presence(
|
||||||
activity=discord.Activity(
|
activity=discord.Activity(
|
||||||
name=f"@{self.user.name}",
|
name=f"@{self.user.name}",
|
||||||
|
@ -179,6 +182,8 @@ class Bot(commands.Bot):
|
||||||
status=discord.Status.online
|
status=discord.Status.online
|
||||||
)
|
)
|
||||||
|
|
||||||
|
asyncio.create_task(presence_task())
|
||||||
|
|
||||||
# NOTE Rethink Entry Point
|
# NOTE Rethink Entry Point
|
||||||
# Initializes all rethink stuff
|
# Initializes all rethink stuff
|
||||||
if hasattr(self, 'rdb') and not self.rtables:
|
if hasattr(self, 'rdb') and not self.rtables:
|
||||||
|
@ -199,7 +204,7 @@ class Bot(commands.Bot):
|
||||||
msg += "-----------------------------\n"
|
msg += "-----------------------------\n"
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
await self.logging.info(content=msg, name="On Ready")
|
self.logging.info(content=msg, name="On Ready")
|
||||||
|
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
"""Handles what the bot does whenever a message comes across."""
|
"""Handles what the bot does whenever a message comes across."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue