diff --git a/bots/bots.go b/bots/bots.go index f74c1e6..ecb6682 100644 --- a/bots/bots.go +++ b/bots/bots.go @@ -56,14 +56,16 @@ func BotStart() { } //set socks5 if config.Socks5 != "" { - fmt.Println("Proxy:" + config.Socks5) + fmt.Println("Proxy: " + config.Socks5) dialer, err := proxy.SOCKS5("tcp", config.Socks5, nil, proxy.Direct) if err != nil { - zap.S().Errorw("failed to make dialer", "error", err, "socks5", config.Socks5) + zap.S().Errorw("failed to get dialer", + "error", err, "proxy", config.Socks5) } httpTransport := &http.Transport{} - httpClient := &http.Client{Transport: httpTransport} httpTransport.Dial = dialer.Dial + httpClient := &http.Client{Transport: httpTransport} + botSetting.Client = httpClient } //create bot diff --git a/config/config.go b/config/config.go index 25e7c99..97e23e8 100644 --- a/config/config.go +++ b/config/config.go @@ -41,7 +41,11 @@ func InitConfig() { zap.S().Errorw("failed to read config", "error", err) } BotToken = viper.GetString("bot_token") + Cron = viper.GetString("cron") Socks5 = viper.GetString("socks5") + //if Socks5[:5] != "socks5" { + // Socks5 = "socks5://" + Socks5 + //} viper.SetDefault("errlimit", 5) viper.SetDefault("bindmax", 5) @@ -49,7 +53,7 @@ func InitConfig() { BindMaxNum = viper.GetInt("bindmax") MaxErrTimes = viper.GetInt("errlimit") Notice = viper.GetString("notice") - Cron = viper.GetString("cron") + MaxGoroutines = viper.GetInt("goroutine") Admins = getAdmins()