Skip to content

Instantly share code, notes, and snippets.

@stephenyeargin
Last active February 16, 2017 15:33
Show Gist options
  • Select an option

  • Save stephenyeargin/8175153 to your computer and use it in GitHub Desktop.

Select an option

Save stephenyeargin/8175153 to your computer and use it in GitHub Desktop.
NashvillePollen hubot script.
# Description
# Get pollen forecast for Nashville, Tennessee
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot pollen - Gets pollen status for Nashville, Tennessee
#
# Notes:
# Uses the pollen forecast that powers https://twitter.com/NashvillePollen
#
# Author:
# stephenyeargin
# jt2k
api_url = 'https://jasontan.org/api/pollen'
module.exports = (robot) ->
robot.respond /pollen/i, (msg) ->
msg.http(api_url)
.get() (err,res,body) ->
try
result = JSON.parse(body)
if result.error
msg.send result.error
else
msg.send "Nashville pollen level: #{result.count} (#{result.level}) - #{result.types}"
catch error
msg.send "Could not retrieve pollen data."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment