Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #570 from brandonvalentine/master

Improve insult script
  • Loading branch information...
commit 5a2c07ee533f438268bc404320f53b65013ff7c7 2 parents 0cfbc36 + 7468d93
@technicalpickles technicalpickles authored
Showing with 16 additions and 13 deletions.
  1. +16 −13 src/scripts/insult.coffee
View
29 src/scripts/insult.coffee
@@ -1,8 +1,8 @@
# Description:
-# None
+# Allows Hubot to lambast someone with a random insult
#
# Dependencies:
-# None
+# "cheerio: "0.7.0"
#
# Configuration:
# None
@@ -10,20 +10,23 @@
# Commands:
# hubot insult <name> - give <name> the what-for
#
-# Author:
-# ajacksified
+# Authors:
+# ajacksified, brandonvalentine
+
+cheerio = require('cheerio')
module.exports = (robot) ->
robot.respond /insult (.*)/i, (msg) ->
name = msg.match[1].trim()
- msg.send(insult(name))
+ insult(msg, name)
-insult = (name) ->
- insults[(Math.random() * insults.length) >> 0].replace(/{name}/, name);
+insult = (msg, name) ->
+ msg
+ .http("http://www.randominsults.net")
+ .header("User-Agent: Insultbot for Hubot (+https://github.com/github/hubot-scripts)")
+ .get() (err, res, body) ->
+ msg.send "#{name}: #{getQuote body}"
-insults = [
- "{name} is a scoundrel.",
- "{name} should be ashamed of himself.",
- "{name} is a motherless son of a goat.",
- "{name} is a gravy-sucking pig."
-]
+getQuote = (body) ->
+ $ = cheerio.load(body)
+ $('i').text()
Please sign in to comment.
Something went wrong with that request. Please try again.