diff --git a/cogs/text_service_cog.py b/cogs/text_service_cog.py index 74060fd..20eab2d 100644 --- a/cogs/text_service_cog.py +++ b/cogs/text_service_cog.py @@ -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 diff --git a/detailed_guides/INSTALLATION.md b/detailed_guides/INSTALLATION.md index cfa48ad..51a2785 100644 --- a/detailed_guides/INSTALLATION.md +++ b/detailed_guides/INSTALLATION.md @@ -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 = "" @@ -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 diff --git a/sample.env b/sample.env index 052423f..2b99e7c 100644 --- a/sample.env +++ b/sample.env @@ -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 \ No newline at end of file +MAX_DEEP_COMPOSE_PRICE = 3.00 + +# Determines if the bot responds to messages that start with a mention of it +BOT_TAGGABLE = "true" \ No newline at end of file diff --git a/services/environment_service.py b/services/environment_service.py index 3ea22b3..c4a873a 100644 --- a/services/environment_service.py +++ b/services/environment_service.py @@ -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: