| 62 | var botTokenRegex = regexp.MustCompile(`MULTI\_TOKEN\d+=(.*)`) |
| 63 | |
| 64 | func (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 | |
| 80 | func SetFlagsFromConfig(cmd *cobra.Command) { |
| 81 | cmd.Flags().Int32("api-id", ValueOf.ApiID, "Telegram API ID") |