Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (28 sloc) 0.877 kb
# Description:
# Define terms via Urban Dictionary
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot urban me <term> - Searches Urban Dictionary and returns definition
# hubot urban define me <term> - Searches Urban Dictionary and returns definition
# hubot urban example me <term> - Searches Urban Dictionary and returns example
#
# Author:
# Travis Jeffery (@travisjeffery)
# FIXME merge with whatis.coffee
module.exports = (robot) ->
robot.respond /(urban)( define)?( example)?( me)? (.*)/i, (msg) ->
urbanDict msg, msg.match[5], (entry) ->
if msg.match[3]
msg.send "#{entry.example}"
else
msg.send "#{entry.definition}"
urbanDict = (msg, query, callback) ->
msg.http("http://urbandict.me/api/#{escape(query)}")
.get() (err, res, body) ->
callback(JSON.parse(body).entries[0])
Jump to Line
Something went wrong with that request. Please try again.