Skip to content

Commit

Permalink
fix: env file is no more a requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
EverythingSuckz committed Nov 29, 2023
1 parent 1eb5c78 commit 1063889
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ vendor/
go.work

# Env files
*.env
fsb.env
.env

# Session files
*.session*
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
31 changes: 31 additions & 0 deletions fsb.sample.env
Original file line number Diff line number Diff line change
@@ -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://<ip address>:<PORT>
# 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

0 comments on commit 1063889

Please sign in to comment.