.env file support#612
Merged
Casimir255 merged 2 commits intoTorchAPI:masterfrom Oct 8, 2025
Merged
Conversation
Contributor
Author
|
@Casimir255 embedded the code, also added friendly log with mask: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhancement
.envfile.Context
.envfiles before, please shoot me a DM and I will explain further.I'm maintaining a live Torch project which you've added to Torch discord:

That project is public so I can't push config files like below:
They're currently
.gitignored like this:but this is taking away the entirity of these files from the project's users.
Naturally, I would send PR to these plugins to read from env vars (if the credential text was empty in their config file). I've already sent one to SEDB for example. That allows me to publish these config files without exposing my own credentials.
Then there's a new problem: if multiple Torch instances had to run in the same host server, those credentials would potentially collide with each other. For example, each instance may wish to use different Discord tokens,
.envfile would help mitigate that problem. In SEDB's case, user could create an.envfile in the working directory as follows:This PR makes Torch load this file and overwrite (or load new)
DISCORD_TOKENenvironment variablefoobar, so that SEDB plugin could pick up and use that token, even if the host system/user env vars aren't set..envfile can be.gitignored, so the token won't go public.From plugins' perspective, these variables are accessible as regular environment variables like
Environment.GetEnvironmentVariable(key). So the plugin devs don't have to know where the variables are coming from.Implementation Details
.envfile from the working directory (i.e. same folder asTorch.Server.exe).Tests