Skip to content

Commit aa4e92d

Browse files
author
RedTea
authored
Merge pull request #59 from RedTeaDev/AIChatModeration
Add AI chat moderation
2 parents b860e7b + e055398 commit aa4e92d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
aiohttp>=3.6.2
22
async-timeout>=3.0.1
33
attrs>=19.3.0
4-
beautifulsoup4>=4.9.1
4+
beautifulsoup4>=4.10.0
55
bs4>=0.0.1
6-
certifi>=2020.6.20
6+
certifi>=2021.5.30
77
chardet>=3.0.4
8-
discord.py>=1.7.2
8+
discord.py>=1.7.3
99
idna>=2.10
1010
lavalink>=3.1.2
1111
multidict>=4.7.6
@@ -19,3 +19,4 @@ urllib3>=1.25.10
1919
websockets>=8.1
2020
yarl>=1.5.1
2121
mysql-connector-python>=8.0.21
22+
alt-profanity-check==1.0

teapot/events.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import teapot
33
import discord
4+
from profanity_check import predict_prob
45

56

67
def __init__(bot):
@@ -48,11 +49,7 @@ def on_guild_join(bot):
4849
@bot.event
4950
async def on_guild_join(ctx):
5051
if teapot.config.storage_type() == "mysql":
51-
try:
52-
teapot.database.create_guild_table(ctx.guild)
53-
except AttributeError as ignored:
54-
pass
55-
52+
teapot.database.create_guild_table(ctx.guild)
5653

5754

5855
def message_send(bot):
@@ -92,6 +89,13 @@ async def on_message(message):
9289
if char not in punctuations:
9390
msg = msg + char
9491

92+
# profanity check
93+
prob = predict_prob([msg])
94+
if prob >= 0.8:
95+
em = discord.Embed(title=f"AI Analysis Results", color=0xC54B4F)
96+
em.add_field(name='PROFANITY DETECTED! ', value=str(prob[0]))
97+
await message.channel.send(embed=em)
98+
9599
if msg.startswith("system call "):
96100
content = msg[12:].split(" ")
97101
if content[0].lower() == "inspect":

0 commit comments

Comments
 (0)