python273 / telegraph

Telegraph API wrapper | Telegra.ph
https://pypi.org/project/telegraph/
MIT License
286 stars 43 forks source link

add socks5h support #22

Open kuhytitusdlz opened 4 years ago

kuhytitusdlz commented 4 years ago

hello, telegra.ph is blocked in our country, and we use proxy. So, please add support socks5h, like in https://github.com/python-telegram-bot/python-telegram-bot

REQUEST_KWARGS = {'proxy_url': 'socks5h://127.0.0.1:9050',} updater = Updater(token=TOKEN, request_kwargs=REQUEST_KWARGS, use_context=True)

python273 commented 4 years ago

It's using requests under the hood, which supports socks5 proxies. I think you can set it via telegraph._telegraph.proxies (also probably you need to pip install requests[socks])

Maybe we can allow to pass TelegraphApi instance to Telegraph via arg. And allow to pass requests session to TelegraphApi. PR is welcome

kuhytitusdlz commented 4 years ago

it's not working telegraph._telegraph.proxies = dict(https='socks5h://localhost:9050') AttributeError: 'TelegraphApi' object has no attribute 'proxies'

python273 commented 4 years ago

oops, it's telegraph._telegraph.session.proxies

kuhytitusdlz commented 4 years ago

it's works, thanks! goodbye roskomndzor J telegraph._telegraph.session.proxies = {'https':'socks5h://localhost:9050'}