From f7b5c23c212c01372bd0c8613124577b9a00944a Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Tue, 3 Apr 2012 12:47:00 -0500 Subject: [PATCH 1/7] Adding solr script. --- package.json | 3 ++- src/scripts/solr.coffee | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/scripts/solr.coffee diff --git a/package.json b/package.json index 847dc8e8f..e570a7ef2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "githubot": "0.1.4", "sandbox": "0.8.2", "prowler": "0.0.3", - "handlebars": ">= 1.0.5beta" + "handlebars": ">= 1.0.5beta", + "solr": "0.2.1" }, "directories": { diff --git a/src/scripts/solr.coffee b/src/scripts/solr.coffee new file mode 100644 index 000000000..14542fb93 --- /dev/null +++ b/src/scripts/solr.coffee @@ -0,0 +1,36 @@ +solr = require 'solr' +crypto = require 'crypto' + +module.exports = (robot) -> + # See node-solr/lib/solr.js for info about the options. + options = + host: if process.env.HUBOT_SOLR_HOST then process.env.HUBOT_SOLR_HOST else '127.0.0.1' + port: if process.env.HUBOT_SOLR_PORT then process.env.HUBOT_SOLR_PORT else '8983' + core: if process.env.HUBOT_SOLR_CORE then process.env.HUBOT_SOLR_CORE else '' + path: if process.env.HUBOT_SOLR_PATH then process.env.HUBOT_SOLR_PATH else '/solr' + + client = solr.createClient(options) + robot.hear /./, (msg) -> + id = crypto.createHash('md5') + .update( + Date.now + + msg.message.user.room + + msg.message.user.name + + msg.message.text, + 'utf8' + ) + .digest('hex') + doc = + id: id + channel_t: msg.message.user.room + nick_t: msg.message.user.name + message_t: msg.message.text + client.add doc, (err) -> + if err + console.error err + return + client.commit (err) -> + if err + console.error err + return + From 861b9181ba7fd33446c1e761a387d294d357f77b Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Tue, 3 Apr 2012 10:55:34 -0700 Subject: [PATCH 2/7] Adding script comment. --- src/scripts/solr.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/scripts/solr.coffee b/src/scripts/solr.coffee index 14542fb93..189ad7e85 100644 --- a/src/scripts/solr.coffee +++ b/src/scripts/solr.coffee @@ -1,3 +1,12 @@ +# Index chat logs in Apache Solr +# +# You can set the following variables: +# HUBOT_SOLR_HOST = "127.0.0.1" +# HUBOT_SOLR_PORT = "8983" +# HUBOT_SOLR_CORE = "/hubot" +# HUBOT_SOLR_PATH = "/solr" +# + solr = require 'solr' crypto = require 'crypto' From aaa5f59a20ef0d87e16a9148aadec4d70fdaeb44 Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Tue, 3 Apr 2012 11:13:16 -0700 Subject: [PATCH 3/7] Use normal coffeescript syntax where it makes sense. --- src/scripts/solr.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/solr.coffee b/src/scripts/solr.coffee index 189ad7e85..207294e0a 100644 --- a/src/scripts/solr.coffee +++ b/src/scripts/solr.coffee @@ -18,7 +18,7 @@ module.exports = (robot) -> core: if process.env.HUBOT_SOLR_CORE then process.env.HUBOT_SOLR_CORE else '' path: if process.env.HUBOT_SOLR_PATH then process.env.HUBOT_SOLR_PATH else '/solr' - client = solr.createClient(options) + client = solr.createClient options robot.hear /./, (msg) -> id = crypto.createHash('md5') .update( From 2f17bb6ef4d95c2f65aaf01bb7f924f7b63e18c8 Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Fri, 4 May 2012 23:40:30 -0500 Subject: [PATCH 4/7] Revert "Use normal coffeescript syntax where it makes sense." This reverts commit aaa5f59a20ef0d87e16a9148aadec4d70fdaeb44. --- src/scripts/solr.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/solr.coffee b/src/scripts/solr.coffee index 207294e0a..189ad7e85 100644 --- a/src/scripts/solr.coffee +++ b/src/scripts/solr.coffee @@ -18,7 +18,7 @@ module.exports = (robot) -> core: if process.env.HUBOT_SOLR_CORE then process.env.HUBOT_SOLR_CORE else '' path: if process.env.HUBOT_SOLR_PATH then process.env.HUBOT_SOLR_PATH else '/solr' - client = solr.createClient options + client = solr.createClient(options) robot.hear /./, (msg) -> id = crypto.createHash('md5') .update( From a9a38aef9d0713c6e88a91fe63e7fbf94b3bd7f2 Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Fri, 4 May 2012 23:40:38 -0500 Subject: [PATCH 5/7] Revert "Adding script comment." This reverts commit 861b9181ba7fd33446c1e761a387d294d357f77b. --- src/scripts/solr.coffee | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/scripts/solr.coffee b/src/scripts/solr.coffee index 189ad7e85..14542fb93 100644 --- a/src/scripts/solr.coffee +++ b/src/scripts/solr.coffee @@ -1,12 +1,3 @@ -# Index chat logs in Apache Solr -# -# You can set the following variables: -# HUBOT_SOLR_HOST = "127.0.0.1" -# HUBOT_SOLR_PORT = "8983" -# HUBOT_SOLR_CORE = "/hubot" -# HUBOT_SOLR_PATH = "/solr" -# - solr = require 'solr' crypto = require 'crypto' From ceff5ca02ee943d4a86885528807bb2d6211517f Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Fri, 4 May 2012 23:40:43 -0500 Subject: [PATCH 6/7] Revert "Adding solr script." This reverts commit f7b5c23c212c01372bd0c8613124577b9a00944a. --- package.json | 3 +-- src/scripts/solr.coffee | 36 ------------------------------------ 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 src/scripts/solr.coffee diff --git a/package.json b/package.json index e570a7ef2..847dc8e8f 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,7 @@ "githubot": "0.1.4", "sandbox": "0.8.2", "prowler": "0.0.3", - "handlebars": ">= 1.0.5beta", - "solr": "0.2.1" + "handlebars": ">= 1.0.5beta" }, "directories": { diff --git a/src/scripts/solr.coffee b/src/scripts/solr.coffee deleted file mode 100644 index 14542fb93..000000000 --- a/src/scripts/solr.coffee +++ /dev/null @@ -1,36 +0,0 @@ -solr = require 'solr' -crypto = require 'crypto' - -module.exports = (robot) -> - # See node-solr/lib/solr.js for info about the options. - options = - host: if process.env.HUBOT_SOLR_HOST then process.env.HUBOT_SOLR_HOST else '127.0.0.1' - port: if process.env.HUBOT_SOLR_PORT then process.env.HUBOT_SOLR_PORT else '8983' - core: if process.env.HUBOT_SOLR_CORE then process.env.HUBOT_SOLR_CORE else '' - path: if process.env.HUBOT_SOLR_PATH then process.env.HUBOT_SOLR_PATH else '/solr' - - client = solr.createClient(options) - robot.hear /./, (msg) -> - id = crypto.createHash('md5') - .update( - Date.now + - msg.message.user.room + - msg.message.user.name + - msg.message.text, - 'utf8' - ) - .digest('hex') - doc = - id: id - channel_t: msg.message.user.room - nick_t: msg.message.user.name - message_t: msg.message.text - client.add doc, (err) -> - if err - console.error err - return - client.commit (err) -> - if err - console.error err - return - From 74c9b6545da494e0981d59ab6a0f339a7992ff6b Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Fri, 4 May 2012 23:43:22 -0500 Subject: [PATCH 7/7] Random Austin memes. --- src/scripts/wheninaustin.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/scripts/wheninaustin.coffee diff --git a/src/scripts/wheninaustin.coffee b/src/scripts/wheninaustin.coffee new file mode 100644 index 000000000..d6264b867 --- /dev/null +++ b/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) +