Skip to content

Instantly share code, notes, and snippets.

@siteshen
Created August 24, 2015 06:13
Show Gist options
  • Select an option

  • Save siteshen/a708e2ab33601bd6e74b to your computer and use it in GitHub Desktop.

Select an option

Save siteshen/a708e2ab33601bd6e74b to your computer and use it in GitHub Desktop.
BearyChat python client
#!/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