datamachine / twx.botapi

Unofficial Telegram Bot API Client
MIT License
238 stars 46 forks source link

Not working through proxies #30

Closed jsanchezf closed 6 years ago

jsanchezf commented 6 years ago

There does not seem to be a way to have it (3.1.1) work through web proxies. It uses the requests module and it is supposed to honor the HTTP_PROXY and HTTPS_PROXY environment variables (a look at the code shows the traditional, lower case versions of them are supported too).

However, the botapi somehow does not seem to trigger the logic in requests. I have been testing with requests version 2.10.0, but the issue list for requests, though full of proxy-related cases, does not seem to have anything on something this simple.

I have managed to make the botapi work through proxies by adding a line: s.proxies = {'http':os.environ['http_proxy'], 'https':os.environ['https_proxy']} in _async_call (after importing os, of course).

However, I think a proper solution would be helpful to everyone.

Surye commented 6 years ago

I think this is because we are creating a new Session from scratch. I'm going to just pull in your solution as it addresses the issue.