Compare commits

...

2 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire 4cbca297b3 App
- Use environment variable rather for config
2023-07-04 18:08:20 +02:00
Tristan B. Velloza Kildaire 8a62c93a6c Updated docs 2023-07-04 18:01:10 +02:00
2 changed files with 14 additions and 13 deletions

View File

@ -57,7 +57,10 @@ An example configuration file can look as follows:
"port": 6667,
"nickname": "tlangbot",
"realname": "TLang Development Bot",
"channel": "#tlang"
"channels": {
"tlang" : "#tlang",
"repoName" : "#destinationChannel"
}
},
"ntfy": {
"endpoint": "http://ntfy.sh",
@ -66,7 +69,7 @@ An example configuration file can look as follows:
}
```
You can also run the program with `gitea-irc-bot myConfig.json` to specify a custom JSON configuration path other than the default.
You can run the program with `GIB_CONFIG=myConfig.json gitea-irc-bot` to specify a custom JSON configuration path other than the default.
## License

View File

@ -251,29 +251,27 @@ void notifySH(string message)
}
}
void main(string[] args)
void main()
{
string configFilePath;
/* If given an argument then use it as the configuration file */
if(args.length == 2)
import std.process : environment;
/* If given an environment variable then use it as the configuration file */
if(environment.get("GIB_CONFIG") !is null)
{
/* Configuration file path */
configFilePath = args[1];
configFilePath = environment.get("GIB_CONFIG");
}
/* If we have more than two arguments then it is an error */
else if(args.length > 2)
{
logger.error("Only one argument, the path to the configuration file, is allowed");
exit(-1);
}
/* If there are no arguments, assume default config.json file */
/* If there is no environment variable, assume default config.json file */
else
{
/* Set to the default config path */
configFilePath = "config.json";
}
try
{
File configFile;