Skip to content

Instantly share code, notes, and snippets.

@adamgoose
Created December 15, 2013 23:27
Show Gist options
  • Save adamgoose/7979820 to your computer and use it in GitHub Desktop.
Save adamgoose/7979820 to your computer and use it in GitHub Desktop.
Laravel Doc finder for [hubot](http://hubot.github.com)
# Description
# docs will search the Laravel documentation
#
# Dependencies:
# none
#
# Configuration:
# none
#
# Commands:
# hubot ldocs <query> - returns a link that matches the query
module.exports = (robot) ->
robot.hear /(.*)? !docs (.*)/i, (msg) ->
msg.http('http://ajax.googleapis.com/ajax/services/search/web')
.query(v: '1.0', q: "#{ msg.match[2] } site:laravel.com")
.get() (err, res, body) ->
results = JSON.parse(body).responseData?.results
if results?.length > 0
url = results[0].unescapedUrl
msg.send "#{ msg.match[1] } Here you go! #{ url }"
else
msg.send "I couldn't find anything..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment