move bot taggable into an environment variable

Kaveen Kumarasinghe 2 years ago
parent 9703e7cc05
commit b92f445fc3

@ -37,6 +37,7 @@ USER_KEY_DB = EnvService.get_api_db()
CHAT_BYPASS_ROLES = EnvService.get_bypass_roles()
PRE_MODERATE = EnvService.get_premoderate()
FORCE_ENGLISH = EnvService.get_force_english()
BOT_TAGGABLE = EnvService.get_bot_is_taggable()
#
# Obtain the Moderation table and the General table, these are two SQLite tables that contain
@ -595,6 +596,9 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
if f"<@{self.bot.user.id}>" in message.content and not (
"@everyone" in message.content or "@here" in message.content
):
if not BOT_TAGGABLE:
return
# Remove the mention from the message
prompt = message.content.replace(self.bot.user.mention, "")
# If the message is empty, don't process it

@ -20,7 +20,7 @@ python3.9 -m pip install -r requirements.txt
OpenAI API Key (https://beta.openai.com/docs/api-reference/introduction)
Discord Bot Token (https://discord.com/developers/applications)
The bot uses an environment file named `.env` to configure it. This file must be named exactly `.env` and placed in the same directory as `gpt3discord.py`. Within this file, you need to fill in your `OPENAI_TOKEN`, `DISCORD_TOKEN`, `DEBUG_SERVER`, and `DEBUG_CHANNEL`, and `ALLOWED_GUILDS` to get the bot to work. There are also many other configurable options, an example `.env` file is shown below.
```shell
OPENAI_TOKEN = "<openai_api_token>"
@ -40,7 +40,9 @@ USER_INPUT_API_KEYS="False" # If True, users must use their own API keys for Ope
# Moderations Service alert channel, this is where moderation alerts will be sent as a default if enabled
MODERATIONS_ALERT_CHANNEL = "977697652147892304"
# User API key db path configuration. This is where the user API keys will be stored.
USER_KEY_DB_PATH = "user_key_db.sqlite"
USER_KEY_DB_PATH = "user_key_db.sqlite"
# Determines if the bot responds to messages that start with a mention of it
BOT_TAGGABLE = "true"
```
# Installation

@ -50,4 +50,7 @@ WELCOME_MESSAGE = "Hi There! Welcome to our Discord server. We hope you'll enjoy
MAX_SEARCH_PRICE = 1.00
# Max price to pay for a deep composition
MAX_DEEP_COMPOSE_PRICE = 3.00
MAX_DEEP_COMPOSE_PRICE = 3.00
# Determines if the bot responds to messages that start with a mention of it
BOT_TAGGABLE = "true"

@ -286,6 +286,16 @@ class EnvService:
except Exception:
return False
@staticmethod
def get_bot_is_taggable():
try:
user_input_api_keys = os.getenv("BOT_TAGGABLE")
if user_input_api_keys.lower().strip() == "true":
return True
return False
except Exception:
return False
@staticmethod
def get_user_key_db_path() -> Union[Path, None]:
try:

Loading…
Cancel
Save