Skip to content

Instantly share code, notes, and snippets.

@woohgit
Last active August 21, 2017 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woohgit/81c145bb332beb6aa88f1078bc3cdd8d to your computer and use it in GitHub Desktop.
Save woohgit/81c145bb332beb6aa88f1078bc3cdd8d to your computer and use it in GitHub Desktop.
Earthquake feed for HipChat - card type message
url = "http://earthquake-report.com/feeds/recent-eq?json"
try:
entries = json.loads(urllib.urlopen(url).read())
for entry in entries:
if "JAPAN" in entry['location'].upper():
jishin = entry
break
except Exception:
pass
card1 = {
"id": str(uuid.uuid4()),
"icon": {"url": "http://icooon-mono.com/i/icon_15889/icon_158890_256.png"},
"url": jishin["link"],
"style": "application",
"format": "medium",
"attributes": [
{
"value": {
"label": jishin["location"].lower()
},
"label": "Location"
},
{
"value": {
"label": "%s %s" % (jishin["date_time"].split("T")[0],
jishin["date_time"].split("T")[1].split("+")[0])
},
"label": "Date"},
{
"value": {
"style": "lozenge-current",
"label": jishin["magnitude"]
},
"label": "Magnitude"}
],
"title": jishin["title"],
"activity": {
"html": jishin["title"],
"icon": "http://icooon-mono.com/i/icon_15889/icon_158890_256.png"
},
# "description": {
# "value": "", "format": "html"
# }}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment