         response = user + ": " + response
 
       if version == 'php' and /function/.test url
-          robot.http(url).get() (err, res, body) ->
-            $ = cheerio.load body
-            methodSigContent = htmlStrip.html_strip $('.methodsynopsis').html(), compact_whitespace : true
-            msg.send response + " | #{methodSigContent}"
+        robot.http(url).get() (err, res, body) ->
+          $ = cheerio.load body
+          methodSigContent = htmlStrip.html_strip $('.methodsynopsis').html(), compact_whitespace : true
+          msg.send response + " | #{methodSigContent}"
       else
         if !url
           msg.send "No results for \"#{query}\""

#   None

cheerio   = require 'cheerio'
htmlStrip = require('htmlstrip-native');
API_URL   = 'http://ajax.googleapis.com/ajax/services/search/web'

module.exports = (robot) ->
  getQueryUrl = (version, query) ->

    else if version == 'api'
      "site:laravel.com/api/4.1 #{query}"
    else if version == 'php'
      "site:www.php.net/manual/en #{query}"
    else if version?
      "site:laravel.com/docs/#{version} #{query}"
    else
      "site:laravel.com/docs #{query}"

  fetchResult = (query, callback) ->
    robot.http(SEARCH_URL)
      .header('User-Agent', USER_AGENT)
      .query(q: query)
      .get() (err, res, body) ->
        $ = cheerio.load body
        firstresult = $('li.g').first()
        url = firstresult.find('h3.r a').attr('href')
        jumpto = firstresult.find('.st .f a').attr('href')

        if jumpto?
          url = jumpto
        callback url if callback
  
  # this regex works fine, would like to fix the space after version though
  robot.hear /(([^:,\s!]+)[:,\s]+)?!docs\s([0-9.]+|api|dev|php)?\s?(.*)/i, (msg) ->
    user = msg.match[2]
    version = msg.match[3]
