Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
merge from fork origin
  • Loading branch information
markomanninen committed Nov 23, 2011
1 parent 20393ba commit 38fa0b6
Show file tree
Hide file tree
Showing 93 changed files with 3,100 additions and 100 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,30 @@
v1.1.8
======
* allow people to start tracks - Zach Holman <github.com@zachholman.com>
* simplify local development - atmos

v1.1.7
======
* urban dictionary definitions - Kevin Traver <kevintraver@gmail.com>
* latest tweet from a user - Kevin Traver <kevintraver@gmail.com>
* bit.ly shortening - Kevin Traver <kevintraver@gmail.com>
* Hubot Play support - Zach Holman <github.com@zachholman.com>
* tvshow information - Victor Butler <victorbutler@gmail.com>
* JIRA issue support - crcastle <crcastle@gmail.com>
* lulz scripts can lulzbomb now - atmos
* gaug.es support - Tom Bell <tomb@tombell.org.uk>
* google reader support - Ben Ubois <ben@benubois.com>
* faceup script enhancements - Joe Ekiert <joe.ekiert@gmail.com>
* get a job support - Craig Slusher <cslush@gmail.com>
* website uptime support - lukesmith <stuff@lukesmith.net>
* me gusta support - John-Michael Glenn <phyre19@gmail.com>
* coderwall support - Arlo Carreon <arlo.carreon@gmail.com>
* cheer me up script - Carl Lerche <me@carllerche.com>
* google news scripts - Matt McCormick <mbmccormick@gmail.com>
* various meme generator enhancements - a lot of people :)
* moar shipit images - Raphael Crawford-Marks <raphael.crawfordmarks@gmail.com>


v1.1.4
======
* hubot define me - Pete Nicholls <pete@metanation.com>
Expand Down
6 changes: 6 additions & 0 deletions bin/hubot
@@ -0,0 +1,6 @@
#!/bin/sh

npm install
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"

exec node_modules/.bin/hubot "$@"
4 changes: 2 additions & 2 deletions package.json 100755 → 100644
Expand Up @@ -30,12 +30,12 @@
"underscore": ">= 1.2.1",
"underscore.string": ">= 1.1.6",
"cradle": "0.5.7",
"clark": "*",
"clark": ">= 0.0.3",
"scribe-node": "0.0.20"
},

"directories": {
"lib": "./src"
},
"engine": "node >= 0.4.1 < 0.5.0"
}
}
55 changes: 55 additions & 0 deletions src/scripts/abstract.coffee
@@ -0,0 +1,55 @@
# abstract <topic> - Prints a nice abstract of the given topic.

# Copyright (c) 2011 John Tantalo
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

module.exports = (robot) ->
robot.respond /(abs|abstract) (.+)/i, (res) ->
abstract_url = "http://api.duckduckgo.com/?format=json&q=#{encodeURIComponent(res.match[2])}"
res.http(abstract_url)
.header('User-Agent', 'Hubot Abstract Script')
.get() (err, _, body) ->
return res.send "Sorry, the tubes are broken." if err
data = JSON.parse(body.toString("utf8"))
return unless data
topic = data.RelatedTopics[0] if data.RelatedTopics and data.RelatedTopics.length
if data.AbstractText
# hubot abs numerology
# Numerology is any study of the purported mystical relationship between a count or measurement and life.
# http://en.wikipedia.org/wiki/Numerology
res.send data.AbstractText
res.send data.AbstractURL if data.AbstractURL
else if topic and not /\/c\//.test(topic.FirstURL)
# hubot abs astronomy
# Astronomy is the scientific study of celestial objects.
# http://duckduckgo.com/Astronomy
res.send topic.Text
res.send topic.FirstURL
else if data.Definition
# hubot abs contumacious
# contumacious definition: stubbornly disobedient.
# http://merriam-webster.com/dictionary/contumacious
res.send data.Definition
res.send data.DefinitionURL if data.DefinitionURL
else
res.send "I don't know anything about that."
2 changes: 1 addition & 1 deletion src/scripts/achievement_unlocked.coffee
Expand Up @@ -4,7 +4,7 @@
module.exports = (robot) ->
robot.hear /achievement (get|unlock(ed)?) (.+?)(\s*[^@\s]+@[^@\s]+)?\s*$/i, (msg) ->
caption = msg.match[3]
email = msg.match[4]
email = msg.match[4] || msg.message.user.email_address
url = "http://achievement-unlocked.heroku.com/xbox/#{escape(caption)}.png"
if email
url += "?email=#{escape(email.trim())}.png"
Expand Down
30 changes: 30 additions & 0 deletions src/scripts/animal.coffee
@@ -0,0 +1,30 @@
# Because animals are animals.
#
# animal me - Grab a random gif from http://animalsbeingdicks.com/
#
Select = require("soupselect").select
HtmlParser = require "htmlparser"

module.exports = (robot) ->
robot.respond /animal me/i, (msg) ->
randimalMe msg, (url) ->
msg.send url

randimalMe = (msg, cb) ->
msg.http("http://animalsbeingdicks.com/random")
.get() (err, res, body) ->
console.log res.headers.location
animalMe msg, res.headers.location, (location) ->
cb location

animalMe = (msg, location, cb) ->
msg.http(location)
.get() (err, res, body) ->
handler = new HtmlParser.DefaultHandler()
parser = new HtmlParser.Parser handler

parser.parseComplete body
img = Select handler.dom, "#content .post .entry img"

console.log img
cb img[0].attribs.src
6 changes: 6 additions & 0 deletions src/scripts/bij.coffee
@@ -0,0 +1,6 @@
# EXPERIENCE BIJ
#

module.exports = (robot) ->
robot.hear /bij/i, (msg) ->
msg.send "EXPERIENCE BIJ!"
19 changes: 19 additions & 0 deletions src/scripts/cheer.coffee
@@ -0,0 +1,19 @@
# Feeling depressed?
#
# cheer me up - A little pick me up
module.exports = (robot) ->
robot.respond /cheer me up/i, (msg) ->
aww msg

robot.hear /i( am|'m) emo/i, (msg) ->
msg.send "Let me cheer you up."
aww msg

aww = (msg) ->
msg
.http('http://imgur.com/r/aww.json')
.get() (err, res, body) ->
images = JSON.parse(body)
images = images.gallery
image = msg.random images
msg.send "http://i.imgur.com/#{image.hash}#{image.ext}"
36 changes: 36 additions & 0 deletions src/scripts/chm.coffee
@@ -0,0 +1,36 @@
# Shows a short history lesson of the day from the Computer History Museum.
#
# today in computer history|tdih|chm - Displays the content from the This Day in History page on the Computer History Museum site.
#
Select = require("soupselect").select
HtmlParser = require "htmlparser"

module.exports = (robot) ->
robot.respond /(today in computer history|tdih|chm)$/i, (msg) ->
msg.http("http://www.computerhistory.org/tdih/")
.get() (err, res, body) ->
handler = new HtmlParser.DefaultHandler()
parser = new HtmlParser.Parser handler
parser.parseComplete body

contentEl = Select handler.dom, ".tdihevent p"
return unless contentEl
msg.send date(handler)
msg.send title(contentEl)
for sentence in blurbSentences(contentEl)
msg.send sentence + '.' if sentence and sentence isnt ""

title = (contentEl) ->
trim contentEl[0].children[0].raw

blurbSentences = (contentEl) ->
blurb = trim contentEl[1].children[0].raw
blurb.split('.')

date = (handler) ->
dateEl = Select handler.dom, ".title"
return "" unless dateEl
trim dateEl[0].children[0].raw

trim = (string) ->
return string.replace(/^\s*|\s*$/g, '')
9 changes: 9 additions & 0 deletions src/scripts/clark.coffee
@@ -0,0 +1,9 @@
# clark - build sparklines out of data

clark = require('clark').clark

module.exports = (robot) ->
robot.respond /clark (.*)/i, (msg) ->
data = msg.match[1].trim().split(' ')
msg.send(clark(data))

24 changes: 24 additions & 0 deletions src/scripts/coderwall.coffee
@@ -0,0 +1,24 @@
# Messing around with the Coderwall API.
#
# coderwall <coderwall username> - Returns coder achievements from coderwall.com
#
module.exports = (robot) ->
robot.respond /(coderwall)( me)? (.*)/i, (msg) ->
user = msg.match[3]
msg.http("http://coderwall.com/"+user+".json")
.get() (err, res, body) ->
# If not response bad username
if res.headers['content-length'] <= 1
letter_s = if user.substr(-1)=='s' then '' else 's'
msg.send "Sorry I cannot find "+user+"'"+letter_s+" coderwall"
# Else return the coder badges
else
profile = JSON.parse(body)
# Give an intro to the coderwall profile
resp_str = "";
resp_str += user + "'s coderwall -> http://coderwall.com/"+user + "\n"
# Iterate all badges and continue building string
profile.badges.forEach (badge) ->
resp_str += badge.name + " - " + badge.description + "\n"
# Return response
msg.send resp_str
10 changes: 10 additions & 0 deletions src/scripts/coin.coffee
@@ -0,0 +1,10 @@
# Help decide between two things
#
# throw a coin - Gives you heads or tails
#

thecoin = ["heads", "tails"]

module.exports = (robot) ->
robot.respond /(throw|flip|toss) a coin/i, (msg) ->
msg.reply msg.random thecoin
9 changes: 9 additions & 0 deletions src/scripts/commitmessage.coffee
@@ -0,0 +1,9 @@
# Get a random commit message
#
# commit message - Displays a random commit message

module.exports = (robot) ->
robot.respond /commit message/i, (msg) ->
msg.http("http://whatthecommit.com/index.txt")
.get() (err, res, body) ->
msg.reply body
63 changes: 63 additions & 0 deletions src/scripts/conversation.coffee
@@ -0,0 +1,63 @@
# Extends robot adding conversation features


module.exports = (robot) ->
robot.eatListeners = {}

# Public: Adds a Listener that receives the next message from the user and av
# further processing of it.
#
# user - The user name.
# callback - A Function that is called with a Response object. msg.match[1] w
# contain the message text without the bot name
#
# Returns nothing.
robot.eatOneResponse = (user, callback) ->
robot.eatListeners[user.id] = new Listener(robot, callback)


# Change default receive command, addind processing of eatListeners
robot.origReceive = robot.receive
robot.receive = (message) ->
if robot.eatListeners[message.user.id]?
lst = robot.eatListeners[message.user.id]
delete robot.eatListeners[message.user.id]

if lst.call message
return

# Put back to process next message
robot.eatListeners[message.user.id] = lst

robot.origReceive(message)


# Public: Waits for the next message from the current user.
#
# callback - Called with the user response
#
# Returns nothing.
robot.Response.prototype.waitResponse = (callback) ->
robot.eatOneResponse this.message.user, callback



class Listener
constructor: (@robot, @callback) ->
if robot.enableSlash
@regex = new RegExp("^(?:\/|#{robot.name}:?)\\s*(.*?)\\s*$", 'i')
else
@regex = new RegExp("^#{robot.name}:?\\s*(.*?)\\s*$", 'i')

@matcher = (message) =>
if message.text?
message.text.match @regex

call: (message) =>
if match = @matcher message
@callback new @robot.Response(@robot, message, match)
return true
else
return false


11 changes: 11 additions & 0 deletions src/scripts/cowsay.coffee
@@ -0,0 +1,11 @@
# Cowsay.
#
# cowsay <statement> - Returns a cow that says what you want.

module.exports = (robot) ->
robot.respond /cowsay( me)? (.*)/i, (msg) ->
msg
.http("http://cowsay.morecode.org/say")
.query(format: 'text', message: msg.match[2])
.get() (err, res, body) ->
msg.send body

0 comments on commit 38fa0b6

Please sign in to comment.