I have some Python 3 code and can make it use the module slackclient to post to channels, no problem. However if I run this code from our corporate servers where all traffic needs to go through a proxy it fails. I know the proxy server and port and have to use them to run pip from our servers, like this:
pip install --proxy proxy.evilcorp.com:8080 slackclient
That works great. If I don't proxy the pip, it fails to connect as expected. So that tells me I just need to figure out how to get my slackclient code to use the proxy, but how? Here is my code:
from slackclient import SlackClient
def get_slackclient():
token = "blah-blah-token"
sc = SlackClient(token)
return sc
def post_slackmessage(username,channel,text):
sc = get_slackclient()
try:
sc.api_call("chat.postMessage",channel=channel,text=text,username=username,unfurl_links="true")
except:
print ("failed to post messaage to slack")
post_slackmessage("test_slack", "test", "hurrah it posted")
I just can't seem to figure out where to put proxy settings, I must be missing something simple. I'm open to other outside the box ideas to make this all work but I can't really install anything on the server to make all traffic go through the proxy or change the proxy settings.