Skip to content

Instantly share code, notes, and snippets.

@khorevaa
Created September 1, 2019 16:45
Show Gist options
  • Save khorevaa/8aaa604ecee084c97216138c949a1b97 to your computer and use it in GitHub Desktop.
Save khorevaa/8aaa604ecee084c97216138c949a1b97 to your computer and use it in GitHub Desktop.
Telegram bot with proxy TOR
_ = tgbotapi.SetLogger(logger)
var proxy = "socks5://127.0.0.1:9150" // Tor proxy for testing
//creating the proxyURL
proxyURL, err := url.Parse(proxy)
transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
Proxy: http.ProxyURL(proxyURL),// ignore expired SSL certificates
}
httpClient := http.Client{
Transport: transCfg,
}
mybot, err := tgbotapi.NewBotAPIWithClient(token, &httpClient)
if err != nil {
logger.WithError(err).Panic("Error create new bot")
}
mybot.Debug = true
logger.Debugf("Authorized on account %s", mybot.Self.UserName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment