Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# Description:
# Find a Drupal module using modulepuppy.heroku.com
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot there's a module for <that>
# hubot module me <something> - Returns links to modules or themes on drupal.org
#
# Author:
# henrrrik
module.exports = (robot) ->
robot.hear /there's a module for (.*)/i, (msg) ->
puppySearch msg, msg.match[1]
robot.respond /module me (.*)/i, (msg) ->
puppySearch msg, msg.match[1]
puppySearch = (msg, query) ->
msg.http('http://modulepuppy.heroku.com/search.json')
.query(query: query)
.get() (err, res, body) ->
results = JSON.parse(body)
modules=[]
for result in results[0..30]
modules.push "#{result.project.title}: #{result.project.link}"
if modules.length>0 then msg.send modules.join('\n') else msg.send "Actually, there isn't a module for that!"