Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #400 from elliotttf/wheninaustin
Browse files Browse the repository at this point in the history
Adding wheninaustin.coffee
  • Loading branch information
atmos committed May 5, 2012
2 parents 015e0ce + 74c9b65 commit 867afce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/scripts/wheninaustin.coffee
@@ -0,0 +1,23 @@
# When in Austin.

http = require 'http'
jsdom = require 'jsdom'

module.exports = (robot) ->
robot.respond /when(\s)?in(\s)?austin/i, (msg) ->
options =
host: 'wheninatx.tumblr.com',
port: 80,
path: '/random'

# Random redirects us to another article, grab that url and respond.
http.get options, (res) ->
location = res.headers.location
jsdom.env location, [ 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ], (errors, window) ->
(($) ->
title = $('meta[property="og:title"]').attr('content')
img = $('article p[align="center"] img').attr('src')

msg.send title + ' ' + img
)(window.jQuery)

0 comments on commit 867afce

Please sign in to comment.