Skip to content
This repository
Michael D. Ivey February 07, 2013
file 51 lines (39 sloc) 1.262 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
# Description:
# Make hubot fetch quotes pertaining to the world's best secret agent, Archer.
#
# Dependencies:
# "scraper": "0.0.9"
#
# Configuration:
# None
#
# Commands:
#
# Author:
# rrix

scraper = require 'scraper'

module.exports = (robot) ->

  robot.hear /^loggin/i, (msg) ->
    msg.reply "call Kenny Loggins, 'cuz you're in the DANGER ZONE."

  robot.hear /^sitting down/i, (msg) ->
    msg.reply "What?! At the table? Look, he thinks he's people!"

  robot.hear /archer/i, (msg) ->

    options = {
       'uri': 'http://en.wikiquote.org/wiki/Archer_(TV_series)',
       'headers': {
         'User-Agent': 'User-Agent: Archerbot for Hubot (+https://github.com/github/hubot-scripts)'
       }
    }

    scraper options, (err, jQuery) ->
      throw err if err
      quotes = jQuery("dl").toArray()
      dialog = ''
      quote = quotes[Math.floor(Math.random()*quotes.length)]
      dialog += jQuery(quote).text().trim() + "\n"
      msg.send dialog

  # Make it possible to turn off a few of the more NSFW ones
  unless process.env.HUBOT_ARCHER_SFW

    robot.hear /^benoit/i, (msg) ->
      msg.send "balls"

    robot.hear /love/i, (msg) ->
      msg.reply "And I love that I have an erection... that doesn't involve homeless people."

Something went wrong with that request. Please try again.