diff --git a/README.md b/README.md index 8ec1020..d293956 100644 --- a/README.md +++ b/README.md @@ -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:
> 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")In case that you want to send a simple message: diff --git a/setup.py b/setup.py index dc93b8b..a875e9b 100644 --- a/setup.py +++ b/setup.py @@ -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'], )) diff --git a/slackweb/slackweb.py b/slackweb/slackweb.py index 4cdb35b..f28a193 100644 --- a/slackweb/slackweb.py +++ b/slackweb/slackweb.py @@ -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): """