Skip to content

Commit 1063889

Browse files
fix: env file is no more a requirement
1 parent 1eb5c78 commit 1063889

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ vendor/
1818
go.work
1919

2020
# Env files
21-
*.env
21+
fsb.env
22+
.env
2223

2324
# Session files
2425
*.session*

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ git clone https://github.com/EverythingSuckz/TG-FileStreamBot -b golang
7070
cd TG-FileStreamBot
7171
go build ./cmd/fsb/
7272
chmod +x fsb
73+
mv fsb.sample.env fsb.env
7374
nano fsb.env
7475
# (add your environment variables, see the next section for more info)
7576
./fsb
@@ -80,7 +81,8 @@ and to stop the program,
8081

8182
## Setting up things
8283

83-
If you're locally hosting, create a file named `.env` in the root directory and add all the variables there.
84+
If you're locally hosting, create a file named `fsb.env` in the root directory and add all the variables there.
85+
You may check the `fsb.sample.env`.
8486
An example of `fsb.env` file:
8587

8688
```sh

config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ func (c *config) setupEnvVars(log *zap.Logger) {
3939
log.WithOptions(zap.AddStacktrace(zap.DPanicLevel)).Sugar().Errorf("ENV file not found: %s", envPath)
4040
log.Sugar().Info("Please create fsb.env file")
4141
log.Sugar().Info("For more info, refer: https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#setting-up-things")
42-
os.Exit(1)
42+
log.Sugar().Info("Please ignore this message if you are hosting it in a service like Heroku or other alternatives.")
4343
} else {
44-
panic(err)
44+
log.Fatal("Unknown error while parsing env file.", zap.Error(err))
4545
}
4646
}
4747
err = envconfig.Process("", c)
4848
if err != nil {
49-
panic(err)
49+
log.Fatal("Error while parsing env variables", zap.Error(err))
5050
}
5151
val := reflect.ValueOf(c).Elem()
5252
for _, env := range os.Environ() {

fsb.sample.env

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Required Variables (DO NOT SKIP THESE)
2+
3+
API_ID=
4+
API_HASH=
5+
BOT_TOKEN=
6+
LOG_CHANNEL=
7+
8+
# Optional Variables
9+
10+
PORT=8080
11+
12+
# The length of the hash in your URLs
13+
# https://domain.tld/1254?hash=asd45a
14+
# ^^^^^^
15+
# /
16+
# This is the hash
17+
18+
HASH_LENGTH=6
19+
20+
# you can use IP address
21+
# HOST=http://<ip address>:<PORT>
22+
# Or you can also use a domain name
23+
# HOST=https://example.com
24+
25+
# For muti token support
26+
# Refer https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#use-multiple-bots-to-speed-up
27+
28+
# MULTI_TOKEN1=1857821156:AAEvrINCsduhjkjhahadvHRdk7oF46KZnc
29+
# MULTI_TOKEN2=1355359001:AAF4dgddVVxDCt51FZqy1unh9h0SOTw0gU
30+
# MULTI_TOKEN3=6941936497:AAGJzfoMHXshS8gVcsefUzpwyrbfU7gKRMM
31+
# MULTI_TOKEN4=6546079247:AAF2k3uvO9Hqadfhjaskjds8jnzOAfQYUzTZ

0 commit comments

Comments
 (0)