Skip to content

Commit

Permalink
Move registry_plugins_only to bot config
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed Apr 21, 2024
1 parent 194758d commit 47c70f1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ CONNECTION_URI=mongodb+srv://mongo.net
# A github personal access token with the repo scope to access private repository and update the bot automatically
# GITHUB_TOKEN=abcdef

# If set to true, only plugins that are in the registry can be loaded
# REGISTRY_PLUGINS_ONLY=false

# Client ID for your application, used by logviewer`
# OAUTH2_CLIENT_ID=12345

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ however, insignificant breaking changes do not guarantee a major version bump, s
### Changed

- Plugin registry now loads the local file when it failed to fetch from the repo.
- `registry_plugins_only` is now a configurable option within the bot.

### Removed

Expand Down
8 changes: 5 additions & 3 deletions cogs/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ async def parse_user_input(self, ctx, plugin_name, check_version=False):
plugin = Plugin(user, repo, plugin_name, branch)

else:
if self.bot.config.get("registry_plugins_only"):
if self.bot.config["registry_plugins_only"]:
embed = discord.Embed(
description="This plugin is not in the registry. To install this plugin, "
"you must set `REGISTRY_PLUGINS_ONLY=false` or remove this key in your .env file.",
title="Your bot is only allowed to install plugins from the registry.",
description=f"To override this, run `{self.bot.prefix}config set registry_plugins_only False`. "
"The creators of this bot have no responsibility for any potential damage that "
"the content of 3rd party plugins might cause.",
color=self.bot.error_color,
)
await ctx.send(embed=embed)
Expand Down
2 changes: 1 addition & 1 deletion core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ConfigManager:
"reply_without_command": False,
"anon_reply_without_command": False,
"plain_reply_without_command": False,
"registry_plugins_only": True,
# logging
"log_channel_id": None,
"mention_channel_id": None,
Expand Down Expand Up @@ -167,7 +168,6 @@ class ConfigManager:
"connection_uri": None, # replace mongo uri in the future
"owners": None,
"enable_presence_intent": False,
"registry_plugins_only": False,
# bot
"token": None,
"enable_plugins": True,
Expand Down
10 changes: 9 additions & 1 deletion core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -1181,5 +1181,13 @@
"If this configuration is enabled, only roles that are hoisted (displayed seperately in member list) will be used. If a user has no hoisted roles, it will return 'None'.",
"If you would like to display the top role of a user regardless of if it's hoisted or not, disable `use_hoisted_top_role`."
]
}
},
"registry_plugins_only": {
"default": "True",
"description": "Controls if the bot is only allowed to install plugins specified in the registry.",
"examples": [
"`{prefix}config set registry_plugins_only False`"
],
"notes": []
}
}

0 comments on commit 47c70f1

Please sign in to comment.