Skip to content

Instantly share code, notes, and snippets.

@mmattice
Created February 16, 2015 19:22
Show Gist options
  • Save mmattice/e922b42fda6a0a5551f2 to your computer and use it in GitHub Desktop.
Save mmattice/e922b42fda6a0a5551f2 to your computer and use it in GitHub Desktop.
Slack webhook input
#!/usr/bin/python
import email
import sys
import json
import requests
url = 'https://hooks.slack.com/services/{{{PUT YOUR URL MAGIC HERE}}}'
payload={"channel": "#general", "username": "ContestBot", "icon_emoji": ":ghost:"}
msg = email.message_from_file(sys.stdin)
payload['text'] = "'%s' just submitted a contest entry!" % (msg.get('From'),)
pljson = json.dumps(payload)
r = requests.post(url, data= {'payload' : pljson})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment