From f735b4c4f03e889dcdbec28d0117783472c6d148 Mon Sep 17 00:00:00 2001 From: min4er <36953773+min4er@users.noreply.github.com> Date: Wed, 4 Jul 2018 09:36:36 +0300 Subject: [PATCH] Update bot.go adding ability to connect bot via proxy with authentification --- bot.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bot.go b/bot.go index 3599c86..572f240 100644 --- a/bot.go +++ b/bot.go @@ -65,8 +65,30 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, } method := fmt.Sprintf(APIEndpoint, bot.Token, endpoint) + + // Uncomment for adding ability to connect via proxy + /*proxyStr := "http://proxy.com:3128" + proxyURL, _ := url.Parse(proxyStr) + + transport := &http.Transport{ + Proxy: http.ProxyURL(proxyURL), + } + bot.Client = &http.Client{ + Transport: transport, + } + */ + //================== resp, err := bot.Client.PostForm(method, params) + + // Uncomment for adding auth params to header + /* + auth := "username:password" + basicAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte(auth)) + resp.Header.Add("Proxy-Authorization", basicAuth) + */ + //================== + if err != nil { return APIResponse{}, err }