Created
August 24, 2015 06:13
-
-
Save siteshen/a708e2ab33601bd6e74b to your computer and use it in GitHub Desktop.
BearyChat python client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2 | |
| # -*- coding: utf-8 -*- | |
| import json | |
| import urllib | |
| import urllib2 | |
| def bearychat(url, text, channel=None, markdown=None, attachments=None): | |
| payload = { | |
| 'text': text, | |
| 'markdown': markdown, | |
| 'channel': channel, | |
| 'attachments': attachments, | |
| } | |
| data = {'payload': json.dumps(dict((k, v) for k, v in payload.iteritems() if v is not None))} | |
| urllib2.urlopen(url, urllib.urlencode(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment