Created
December 15, 2013 23:27
-
-
Save adamgoose/7979820 to your computer and use it in GitHub Desktop.
Laravel Doc finder for [hubot](http://hubot.github.com)
This file contains 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
# 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