MCPcopy
hub / github.com/EverythingSuckz/TG-FileStreamBot / loadFromEnvFile

Method loadFromEnvFile

config/config.go:64–78  ·  view source on GitHub ↗
(log *zap.Logger)

Source from the content-addressed store, hash-verified

62var botTokenRegex = regexp.MustCompile(`MULTI\_TOKEN\d+=(.*)`)
63
64func (c *config) loadFromEnvFile(log *zap.Logger) {
65 envPath := filepath.Clean("fsb.env")
66 log.Sugar().Infof("Trying to load ENV vars from %s", envPath)
67 err := godotenv.Load(envPath)
68 if err != nil {
69 if os.IsNotExist(err) {
70 log.Sugar().Errorf("ENV file not found: %s", envPath)
71 log.Sugar().Info("Please create fsb.env file")
72 log.Sugar().Info("For more info, refer: https://github.com/EverythingSuckz/TG-FileStreamBot/tree/golang#setting-up-things")
73 log.Sugar().Info("Please ignore this message if you are hosting it in a service like Heroku or other alternatives.")
74 } else {
75 log.Fatal("Unknown error while parsing env file.", zap.Error(err))
76 }
77 }
78}
79
80func SetFlagsFromConfig(cmd *cobra.Command) {
81 cmd.Flags().Int32("api-id", ValueOf.ApiID, "Telegram API ID")

Callers 1

setupEnvVarsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected