Kaveen Kumarasinghe 1 year ago
parent a20d8d2918
commit 951216fc49

@ -143,6 +143,8 @@ There are two thresholds for the bot, there are instances in which the bot will
If you'd like to help us test and fine tune our thresholds for the moderation service, please join this test server: https://discord.gg/CWhsSgNdrP. You can let off some steam in a controlled environment ;)
To set a certain role immune to moderations, add the line `CHAT_BYPASS_ROLES="Role1,Role2,etc"` to your `.env file.
**The above server is NOT for support or discussions about GPT3Discord**
# Permanent Memory and Conversations

@ -31,6 +31,7 @@ else:
#
USER_INPUT_API_KEYS = EnvService.get_user_input_api_keys()
USER_KEY_DB = EnvService.get_api_db()
CHAT_BYPASS_ROLES = EnvService.get_bypass_roles()
#
# Obtain the Moderation table and the General table, these are two SQLite tables that contain
@ -524,8 +525,7 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
and Moderation.moderation_queues[message.guild.id] is not None
):
# Verify that the user is not in a role that can bypass moderation
if (CHAT_BYPASS_ROLES is not [None]
and message.author.roles is not in CHAT_BYPASS_ROLES):
if CHAT_BYPASS_ROLES is [None] or message.author.roles not in CHAT_BYPASS_ROLES:
# Create a timestamp that is 0.5 seconds from now
timestamp = (
datetime.datetime.now() + datetime.timedelta(seconds=0.5)

@ -268,6 +268,32 @@ class EnvService:
return user_key_db
return user_key_db
@staticmethod
def get_bypass_roles():
# GPT_ROLES is a comma separated list of string roles
# It can also just be one role
# Read these allowed roles and return as a list of strings
try:
bypass_roles = os.getenv("CHAT_BYPASS_ROLES")
except Exception:
bypass_roles = None
if bypass_roles is None:
print(
"CHAT_BYPASS_ROLES is not defined properly in the environment file!"
"Please copy your server's role and put it into CHAT_BYPASS_ROLES in the .env file."
'For example a line should look like: `CHAT_BYPASS_ROLES="bypass"`'
)
print("Defaulting to allowing NO ONE to bypass chat moderation")
return [None]
bypass_roles = (
bypass_roles.lower().strip().split(",")
if "," in bypass_roles
else [bypass_roles.lower()]
)
return bypass_roles
@staticmethod
def get_deepl_token():
try:

@ -158,32 +158,7 @@ class Moderation:
if warn_result:
return ModerationResult.WARN
return ModerationResult.NONE
@staticmethod
def get_bypass_roles():
# GPT_ROLES is a comma separated list of string roles
# It can also just be one role
# Read these allowed roles and return as a list of strings
try:
bypass_roles = os.getenv("CHAT_BYPASS_ROLES")
except Exception:
bypass_roles = None
if bypass_roles is None:
print(
"CHAT_BYPASS_ROLES is not defined properly in the environment file!"
"Please copy your server's role and put it into CHAT_BYPASS_ROLES in the .env file."
'For example a line should look like: `CHAT_BYPASS_ROLES="bypass"`'
)
print("Defaulting to allowing NO ONE to bypass chat moderation")
return [None]
bypass_roles = (
bypass_roles.lower().strip().split(",")
if "," in bypass_roles
else [bypass_roles.lower()]
)
return bypass_roles
# This function will be called by the bot to process the message queue
@staticmethod
async def process_moderation_queue(

@ -9,9 +9,6 @@ from discord.ext import pages
from services.deletion_service import Deletion
from models.openai_model import Model
from models.user_model import EmbeddedConversationItem, RedoUser
CHAT_BYPASS_ROLES = EnvService.get_bypass_roles()
class TextService:
def __init__(self):
pass

Loading…
Cancel
Save