forked from github/hubot-scripts
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
merge from fork origin
- Loading branch information
1 parent
20393ba
commit 38fa0b6
Showing
93 changed files
with
3,100 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# EXPERIENCE BIJ | ||
# | ||
|
||
module.exports = (robot) -> | ||
robot.hear /bij/i, (msg) -> | ||
msg.send "EXPERIENCE BIJ!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.