I just wanted to post information into the slack channel, I'm not interested in getting commands from the channel (although there is a really neat library for that here: viewtopic.php?t=2405)
This is what I came up with:
https://gist.github.com/jeffeb3/d6f7b72 ... 4643282533
Code: Select all
def slack_it(msg):
''' Send a message to a predefined slack channel.'''
import urequests
# Get an "incoming-webhook" URL from your slack account. @see https://api.slack.com/incoming-webhooks
URL='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
headers = {'content-type': 'application/json'}
data = '{"text":"%s"}' % msg
resp = urequests.post(URL, data=data, headers=headers)
return resp