From 10638896fb823fd33f98c1eb0135545a5e3ebc08 Mon Sep 17 00:00:00 2001 From: wrench Date: Wed, 29 Nov 2023 22:08:17 +0530 Subject: [PATCH] fix: env file is no more a requirement --- .gitignore | 3 ++- README.md | 4 +++- config/config.go | 6 +++--- fsb.sample.env | 31 +++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 fsb.sample.env diff --git a/.gitignore b/.gitignore index 76a57e5a..7afc108d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,8 @@ vendor/ go.work # Env files -*.env +fsb.env +.env # Session files *.session* diff --git a/README.md b/README.md index fb07e36c..9e76c045 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ git clone https://github.com/EverythingSuckz/TG-FileStreamBot -b golang cd TG-FileStreamBot go build ./cmd/fsb/ chmod +x fsb +mv fsb.sample.env fsb.env nano fsb.env # (add your environment variables, see the next section for more info) ./fsb @@ -80,7 +81,8 @@ and to stop the program, ## Setting up things -If you're locally hosting, create a file named `.env` in the root directory and add all the variables there. +If you're locally hosting, create a file named `fsb.env` in the root directory and add all the variables there. +You may check the `fsb.sample.env`. An example of `fsb.env` file: ```sh diff --git a/config/config.go b/config/config.go index fc261ede..c41850ee 100644 --- a/config/config.go +++ b/config/config.go @@ -39,14 +39,14 @@ func (c *config) setupEnvVars(log *zap.Logger) { log.WithOptions(zap.AddStacktrace(zap.DPanicLevel)).Sugar().Errorf("ENV file not found: %s", envPath) log.Sugar().Info("Please create fsb.env file") log.Sugar().Info("For more info, refer: https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#setting-up-things") - os.Exit(1) + log.Sugar().Info("Please ignore this message if you are hosting it in a service like Heroku or other alternatives.") } else { - panic(err) + log.Fatal("Unknown error while parsing env file.", zap.Error(err)) } } err = envconfig.Process("", c) if err != nil { - panic(err) + log.Fatal("Error while parsing env variables", zap.Error(err)) } val := reflect.ValueOf(c).Elem() for _, env := range os.Environ() { diff --git a/fsb.sample.env b/fsb.sample.env new file mode 100644 index 00000000..02dec0f5 --- /dev/null +++ b/fsb.sample.env @@ -0,0 +1,31 @@ +# Required Variables (DO NOT SKIP THESE) + +API_ID= +API_HASH= +BOT_TOKEN= +LOG_CHANNEL= + +# Optional Variables + +PORT=8080 + +# The length of the hash in your URLs +# https://domain.tld/1254?hash=asd45a +# ^^^^^^ +# / +# This is the hash + +HASH_LENGTH=6 + +# you can use IP address +# HOST=http://: +# Or you can also use a domain name +# HOST=https://example.com + +# For muti token support +# Refer https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#use-multiple-bots-to-speed-up + +# MULTI_TOKEN1=1857821156:AAEvrINCsduhjkjhahadvHRdk7oF46KZnc +# MULTI_TOKEN2=1355359001:AAF4dgddVVxDCt51FZqy1unh9h0SOTw0gU +# MULTI_TOKEN3=6941936497:AAGJzfoMHXshS8gVcsefUzpwyrbfU7gKRMM +# MULTI_TOKEN4=6546079247:AAF2k3uvO9Hqadfhjaskjds8jnzOAfQYUzTZ \ No newline at end of file