forked from github/hubot-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
15 changed files
with
277 additions
and
17 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
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,15 @@ | ||
# | ||
# achievement get <achievement> [achiever's gravatar email] - life goals are in reach. | ||
# | ||
module.exports = (robot) -> | ||
robot.hear /achievement (get|unlock(ed)?) (.+?)(\s*[^@\s]+@[^@\s]+)?\s*$/i, (msg) -> | ||
caption = msg.match[3] | ||
email = msg.match[4] | ||
url = "http://achievement-unlocked.heroku.com/xbox/#{escape(caption)}.png" | ||
if email | ||
url += "?email=#{escape(email.trim())}.png" | ||
msg.send(url) | ||
|
||
robot.hear /acheivement (get|unlock(ed)?)/i, (msg) -> | ||
url = "http://achievement-unlocked.heroku.com/xbox/#{escape("Bane of Daniel Webster")}.png" | ||
msg.send(url) |
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,7 @@ | ||
# Bees are insane | ||
# | ||
# bees - Oprah at her finest, or a good way to turn the fans on coworkers machines | ||
|
||
module.exports = (robot) -> | ||
robot.respond /bees/i, (message) -> | ||
message.send "http://thechive.files.wordpress.com/2010/11/oprah-bees.gif" |
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,15 @@ | ||
# Returns the URL of the first bing hit for a query | ||
# | ||
# bing me <query> - Bings <query> & returns 1st result's URL | ||
|
||
module.exports = (robot) -> | ||
robot.respond /(bing)( me)? (.*)/i, (msg) -> | ||
bingMe msg, msg.match[3], (url) -> | ||
msg.send url | ||
|
||
bingMe = (msg, query, cb) -> | ||
msg.http('http://www.bing.com/search') | ||
.query(q: query) | ||
.get() (err, res, body) -> | ||
cb body.match(/<div class="sb_tlst"><h3><a href="([^"]*)"/)?[1] || "Sorry, Bing had zero results for '#{query}'" | ||
|
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
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 @@ | ||
# Display current app performance stats from New Relic | ||
# | ||
# You need to set the following variables: | ||
# HUBOT_NEWRELIC_ACCOUNT_ID = "<Account ID>" | ||
# HUBOT_NEWRELIC_APP_ID = "<Application ID>" | ||
# HUBOT_NEWRELIC_API_KEY = "<API Key>" | ||
# | ||
# How to find these settings: | ||
# After signing into New Relic, select your application | ||
# Given: https://rpm.newrelic.com/accounts/xxx/applications/yyy | ||
# xxx is your Account ID and yyy is your App ID | ||
# Account Settings > API + Web Integrations > API Access > "API key" | ||
# | ||
# TODO: | ||
# - Allow hubot to display all app stats for a given account using the View Applications API call | ||
# https://github.com/newrelic/newrelic_api | ||
# - Allow you to specify the name of the app to fetch metrics for: | ||
# hubot newrelic me "My App Name" | ||
# | ||
# hubot <newrelic me> - Returns summary application stats from New Relic | ||
module.exports = (robot) -> | ||
robot.respond /newrelic me/i, (msg) -> | ||
accountId = process.env.HUBOT_NEWRELIC_ACCOUNT_ID | ||
appId = process.env.HUBOT_NEWRELIC_APP_ID | ||
apiKey = process.env.HUBOT_NEWRELIC_API_KEY | ||
Parser = require("xml2js").Parser | ||
|
||
msg.http("https://rpm.newrelic.com/accounts/#{accountId}/applications/#{appId}/threshold_values.xml?api_key=#{apiKey}") | ||
.get() (err, res, body) -> | ||
if err | ||
msg.send "New Relic says: #{err}" | ||
return | ||
(new Parser).parseString body, (err, json)-> | ||
for threshold_value in json['threshold_value'] | ||
msg.send " #{threshold_value['@']['name']} : #{threshold_value['@']['formatted_metric_value']}" | ||
msg.send " https://rpm.newrelic.com/accounts/#{accountId}/applications/#{appId}" |
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,41 @@ | ||
# Get current stories from PivotalTracker | ||
# | ||
# You need to set the following variables: | ||
# HUBOT_PIVOTAL_TOKEN = <API token> | ||
# | ||
# If you're working on a single project, you can set it once: | ||
# HUBOT_PIVOTAL_PROJECT = <project name> | ||
# | ||
# Otherwise, include the project name in your message to Hubot. | ||
# | ||
# show me stories for <project> -- shows current stories being worked on | ||
module.exports = (robot) -> | ||
robot.respond /show\s+(me\s+)?stories\s+(for\s+)?(.*)/i, (msg)-> | ||
Parser = require("xml2js").Parser | ||
token = process.env.HUBOT_PIVOTAL_TOKEN | ||
project_name = msg.match[3] | ||
if project_name == "" | ||
project_name = RegExp(process.env.HUBOT_PIVOTAL_PROJECT, "i") | ||
else | ||
project_name = RegExp(project_name + ".*", "i") | ||
|
||
msg.http("http://www.pivotaltracker.com/services/v3/projects").headers("X-TrackerToken": token).get() (err, res, body) -> | ||
if err | ||
msg.send "Pivotal says: #{err}" | ||
return | ||
(new Parser).parseString body, (err, json)-> | ||
for project in json.project | ||
if project_name.test(project.name) | ||
msg.http("https://www.pivotaltracker.com/services/v3/projects/#{project.id}/stories").headers("X-TrackerToken": token).query(filter: "state:unstarted,started,finished,delivered").get() (err, res, body) -> | ||
if err | ||
msg.send "Pivotal says: #{err}" | ||
return | ||
|
||
(new Parser).parseString body, (err, json)-> | ||
for story in json.story | ||
message = "##{story.id['#']} #{story.name}" | ||
message += " (#{story.owned_by})" if story.owned_by | ||
message += " is #{story.current_state}" if story.current_state && story.current_state != "unstarted" | ||
msg.send message | ||
return | ||
msg.send "No project #{project_name}" |
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,71 @@ | ||
# Basic SendGrid statistics. | ||
# | ||
# Set HUBOT_SENDGRID_USER to your SendGrid username (the same as you use to log in to sendgrid.com) | ||
# Set HUBOT_SENDGRID_KEY to your SendGrid password (the same as you use to log in to sendgrid.com) | ||
# | ||
# sendgrid total - total sendgrid usage for the account | ||
# sendgrid today - Total usage for today | ||
# sendgrid c[ategory] <category> - Today's usage for the given category | ||
|
||
env = process.env | ||
|
||
module.exports = (robot) -> | ||
if env.HUBOT_SENDGRID_USER and env.HUBOT_SENDGRID_KEY | ||
robot.respond /(sendgrid)( me)? today/i, (msg) -> | ||
opts = | ||
days: 0 | ||
query msg, opts, (json) -> | ||
msg.send formatResponse(json[0]) | ||
|
||
robot.respond /(sendgrid)( me)? total/i, (msg) -> | ||
opts = | ||
aggregate: 1 | ||
query msg, opts, (json) -> | ||
msg.send formatResponse(json) | ||
|
||
robot.respond /(sendgrid)( me)? c(ategory)? (.*)/i, (msg) -> | ||
category = msg.match[4] | ||
msg.send "Category: #{category}" | ||
opts = | ||
days: 0 | ||
category: [category] | ||
query msg, opts, (json) -> | ||
msg.send formatResponse(json[0]) | ||
|
||
query = (msg, opts, callback) -> | ||
opts.api_user = env.HUBOT_SENDGRID_USER | ||
opts.api_key = env.HUBOT_SENDGRID_KEY | ||
msg.http("https://sendgrid.com/api/stats.get.json") | ||
.query(opts) | ||
.get() (err, res, body) -> | ||
callback JSON.parse(body) | ||
|
||
stats = | ||
requests: 'Requests' | ||
delivered: 'Delivered' | ||
|
||
bounces: 'Bounces' | ||
repeat_bounces: 'Repeat Bounces' | ||
|
||
invalid_email: 'Invalid Emails' | ||
|
||
opens: 'Opens' | ||
unique_opens: 'Unique Opens' | ||
|
||
clicks: 'Clicks' | ||
unique_clicks: 'Unique Clicks' | ||
|
||
unsubscribes: 'Unsubscribes' | ||
repeat_unsubscribes: 'Repeat Unsubscribes' | ||
|
||
blocked: 'Blocked' | ||
spam_drop: 'Spam Drop' | ||
|
||
spamreports: 'Spam Reports' | ||
repeat_spamreports: 'Repeat Spam Reports' | ||
|
||
formatResponse = (json) => | ||
details = for stat, description of stats | ||
" #{description}: #{json[stat]}" | ||
details.unshift "Stats for #{json.date}:" | ||
details.join("\n") |
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
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,34 @@ | ||
# Dictionary definitions with the Wordnik API. You'll need an API key from http://developer.wordnik.com/ | ||
# | ||
# define me <word> - Grabs a dictionary definition of a word. | ||
module.exports = (robot) -> | ||
robot.respond /define( me)? (.*)/i, (msg) -> | ||
|
||
if process.env.WORDNIK_API_KEY == undefined | ||
msg.send "Missing WORDNIK_API_KEY env variable." | ||
return | ||
|
||
word = msg.match[2] | ||
|
||
msg.http("http://api.wordnik.com/v4/word.json/#{escape(word)}/definitions") | ||
.header('api_key', process.env.WORDNIK_API_KEY) | ||
.get() (err, res, body) -> | ||
definitions = JSON.parse(body) | ||
|
||
if definitions.length == 0 | ||
msg.send "No definitions for \"#{word}\" found." | ||
else | ||
reply = "Definitions for \"#{word}\":\n" | ||
|
||
lastSpeechType = null | ||
definitions = definitions.forEach (def) -> | ||
# Show the part of speech (noun, verb, etc.) when it changes | ||
if def.partOfSpeech != lastSpeechType | ||
reply += " (#{def.partOfSpeech})\n" if def.partOfSpeech != undefined | ||
|
||
lastSpeechType = def.partOfSpeech | ||
|
||
reply += " - #{def.text}\n" | ||
|
||
msg.send reply | ||
|
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,27 @@ | ||
# Grab XKCD comic image urls | ||
# | ||
# xkcd - The latest XKCD comic | ||
# xkcd <num> - XKCD comic matching the supplied number | ||
# | ||
# Examples | ||
# | ||
# xkcd 149 | ||
# # => Sandwich - http://imgs.xkcd.com/comics/sandwich.png | ||
# # => Proper User Policy apparently means Simon Says. | ||
# | ||
module.exports = (robot) -> | ||
robot.respond /xkcd\s?(\d+)?/i, (msg) -> | ||
if msg.match[1] == undefined | ||
num = '' | ||
else | ||
num = "#{msg.match[1]}/" | ||
|
||
msg.http("http://xkcd.com/#{num}info.0.json") | ||
.get() (err, res, body) -> | ||
if res.statusCode == 404 | ||
msg.send 'Comic not found.' | ||
else | ||
object = JSON.parse(body) | ||
msg.send object.alt | ||
msg.send object.title | ||
msg.send object.img |