mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16:19 +00:00
🐛 fix(chat.py): fix typo in message.channel.send() method call
🔒 chore(chat.py): add moderation check for message content in call_function() to prevent sending blocked messages 🔒 chore(chat.py): add moderation check for query in call_function() to prevent sending blocked queries 🔒 chore(makeprompt.py): add moderation check for content in chatgpt_process() to prevent sending blocked content 🔒 chore(makeprompt.py): add depth check to prevent recursive answering in chatgpt_process()
This commit is contained in:
@@ -5,6 +5,7 @@ import aiohttp
|
||||
import random
|
||||
import time
|
||||
|
||||
from utils.misc import moderate
|
||||
from simpleeval import simple_eval
|
||||
from bs4 import BeautifulSoup
|
||||
from src.config import tenor_api_key
|
||||
@@ -331,7 +332,7 @@ async def evaluate_math(
|
||||
return f"Result to math eval of {evaluable}: ```\n{str(result)}```"
|
||||
|
||||
|
||||
async def call_function(message: discord.Message, function_call):
|
||||
async def call_function(message: discord.Message, function_call, api_key):
|
||||
name = function_call.get("name", "")
|
||||
if name == "":
|
||||
raise FuntionCallError("No name provided")
|
||||
@@ -341,6 +342,14 @@ async def call_function(message: discord.Message, function_call):
|
||||
if name not in functions_matching:
|
||||
raise FuntionCallError("Invalid function name")
|
||||
function = functions_matching[name]
|
||||
if arguments.get("message", "") != "" and moderate(
|
||||
api_key=api_key, text=arguments["message"]
|
||||
):
|
||||
return "Message blocked by the moderation system. Please try again."
|
||||
if arguments.get("query", "") != "" and moderate(
|
||||
api_key=api_key, text=arguments["query"]
|
||||
):
|
||||
return "Query blocked by the moderation system. If the user asked for something edgy, please tell them in a funny way that you won't do it, but do not specify that it was blocked by the moderation system."
|
||||
returnable = await function(message, arguments)
|
||||
return returnable
|
||||
|
||||
|
||||
Reference in New Issue
Block a user