Skip to content

Commit e8e48be

Browse files
committed
Add AI chat moderation
Signed-off-by: Sean Cheung <[email protected]>
1 parent b860e7b commit e8e48be

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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)