From e8e48bea48a2e78a4f1faf209df3b7f8410520bb Mon Sep 17 00:00:00 2001 From: Sean Cheung Date: Fri, 1 Oct 2021 01:37:52 +0800 Subject: [PATCH 1/3] Add AI chat moderation Signed-off-by: Sean Cheung --- teapot/events.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/teapot/events.py b/teapot/events.py index 8329a9a..58207b2 100644 --- a/teapot/events.py +++ b/teapot/events.py @@ -1,6 +1,7 @@ import json import teapot import discord +from profanity_check import predict_prob def __init__(bot): @@ -48,11 +49,7 @@ def on_guild_join(bot): @bot.event async def on_guild_join(ctx): if teapot.config.storage_type() == "mysql": - try: - teapot.database.create_guild_table(ctx.guild) - except AttributeError as ignored: - pass - + teapot.database.create_guild_table(ctx.guild) def message_send(bot): @@ -92,6 +89,13 @@ async def on_message(message): if char not in punctuations: msg = msg + char + # profanity check + prob = predict_prob([msg]) + if prob >= 0.8: + em = discord.Embed(title=f"AI Analysis Results", color=0xC54B4F) + em.add_field(name='PROFANITY DETECTED! ', value=str(prob[0])) + await message.channel.send(embed=em) + if msg.startswith("system call "): content = msg[12:].split(" ") if content[0].lower() == "inspect": From 29be1dd9fabf3ee6491f9473730c52d55808a27a Mon Sep 17 00:00:00 2001 From: RedTea Date: Fri, 1 Oct 2021 01:54:20 +0800 Subject: [PATCH 2/3] Update requirements Signed-off-by: Sean Cheung --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index f8f10a9..14883ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,3 +19,4 @@ urllib3>=1.25.10 websockets>=8.1 yarl>=1.5.1 mysql-connector-python>=8.0.21 +alt-profanity-check==1.0 \ No newline at end of file From e0553982460a67234ff4d33c631a69f5d863a4bf Mon Sep 17 00:00:00 2001 From: RedTea Date: Fri, 1 Oct 2021 02:05:22 +0800 Subject: [PATCH 3/3] Upgrade dependency Signed-off-by: Sean Cheung --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 14883ab..b3caa4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ aiohttp>=3.6.2 async-timeout>=3.0.1 attrs>=19.3.0 -beautifulsoup4>=4.9.1 +beautifulsoup4>=4.10.0 bs4>=0.0.1 -certifi>=2020.6.20 +certifi>=2021.5.30 chardet>=3.0.4 -discord.py>=1.7.2 +discord.py>=1.7.3 idna>=2.10 lavalink>=3.1.2 multidict>=4.7.6