Skip to content

Added ability to specify a proxy #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ $ sudo python setup.py install

Get a token of slack webhook on [slack page](https://my.slack.com/services/new/incoming-webhook/).

Instantiate:
Instantiate, with optional proxy:
<pre>
> import slackweb
> slack = slackweb.Slack(url="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
> slack = slackweb.Slack(url="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", proxy="https://proxy.URI")
</pre>

In case that you want to send a simple message:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"License :: OSI Approved :: MIT License"
]
)
setup_options["version"] = "1.0.5"
setup_options["version"] = "1.1.0"
setup_options.update(dict(
packages = ['slackweb'],
))
Expand Down
8 changes: 6 additions & 2 deletions slackweb/slackweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

class Slack():

def __init__(self, url=""):
def __init__(self, url="", proxy=None):
self.url = url
self.opener = urlrequest.build_opener(urlrequest.HTTPHandler())
if proxy:
proxy = {'https': proxy}
self.opener = urlrequest.build_opener(urlrequest.HTTPHandler(), urlrequest.ProxyHandler(proxy))
else:
self.opener = urlrequest.build_opener(urlrequest.HTTPHandler())

def notify(self, **kwargs):
"""
Expand Down