liiight / notifiers

The easy way to send notifications
http://notifiers.readthedocs.io/
MIT License
2.66k stars 107 forks source link

Need proxy support for providers #236

Open fakegit opened 5 years ago

fakegit commented 5 years ago

For me, I need proxy to use telegram and discord, hope this project has proxy support

welcome[bot] commented 5 years ago

Thanks for opening your first issue here! Be sure to follow the issue template! 👋🐞👋

liiight commented 5 years ago

Could you please elaborate on your use case?

fakegit commented 5 years ago

telegram is blocked at where i lived, i must send notification to telegram through proxy, i'd like function like the code bellow:


from notifiers import get_notifier  
proxies = {'http': 'http://127.0.0.1:1080', 'https': 'socks5://127.0.0.1:1080'}
telegram = get_notifier('telegram')  
telegram.notify(message='Hi!', token='TOKEN', chat_id=1234, proxies=proxies)  ```
liiight commented 5 years ago

Yeah, this is very doable. Currently the base URL is a class attribute, but making it passable should be fairly straightforward

liiight commented 5 years ago

Since notifiers uses requests, seems like there's a workaround for this:

$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"

$ python
>>> import requests
>>> requests.get('http://example.org')