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

Commit c8e2b3e

Browse files
author
Gabriel Guzman
committed
Merge branch 'master' of github.com:gabeguz/hubot-scripts into usersupport
2 parents 2be300b + e7846af commit c8e2b3e

File tree

6 files changed

+123
-1
lines changed

6 files changed

+123
-1
lines changed

src/scripts/bitbucket.coffee

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Announce changes to BitBucket repositories using BitBucket's POST service
2+
# to a room sepecified by the URL.
3+
#
4+
# For instructions on how to set up BitBucket's POST service for your repositories,
5+
# visit: http://confluence.atlassian.com/display/BITBUCKET/Setting+Up+the+bitbucket+POST+Service
6+
#
7+
8+
module.exports = (robot) ->
9+
robot.router.post '/hubot/bitbucket/:room', (req, res) ->
10+
room = req.params.room
11+
12+
data = JSON.parse req.body.payload
13+
commits = data.commits
14+
15+
msg = "#{data.user} pushed #{commits.length} commits to #{data.repository.name}:\n\n"
16+
msg += "[#{commit.branch}] #{commit.message}\n" for commit in commits
17+
18+
robot.messageRoom room, msg
19+
20+
res.writeHead 204, { 'Content-Length': 0 }
21+
res.end()

src/scripts/linsanity.coffee

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Display a picture of Jeremy Lin if anyone invokes "linsanity" or says "linspire"
2+
# Cause Lin is Linspiring!
3+
4+
images = [
5+
"http://i.i.com.com/cnwk.1d/i/tim/2012/02/16/Jeremy_Lin_139046190_620x350.jpg"
6+
"http://a.abcnews.com/images/Business/gty_jeremy_lin_ll_120217_wg.jpg"
7+
"http://i.usatoday.net/sports/_photos/2012/02/19/Knicks-guard-Jeremy-Lin-wears-faith-on-wrist-RH11428S-x-large.jpg"
8+
"http://thegospelcoalition.org/blogs/tgc/files/2012/02/Jeremy-Lin.jpg"
9+
"http://www.pennystockicons.com/wp-content/plugins/rss-poster/cache/21952_jeremy-lin.gi.top.jpg"
10+
"http://indiancountrytodaymedianetwork.com/wp-content/uploads/2012/02/JeremyLin-615x599.jpg"
11+
"http://www.chinasmack.com/wp-content/uploads/2012/02/jeremy-lin-new-york-knicks-01.jpg"
12+
"http://www.hollywoodreporter.com/sites/default/files/2012/02/jeremy_lin_3.jpg"
13+
"http://www.wtsp.com/images/640/360/2/assetpool/images/120217125112_jeremy-lin.jpg"
14+
"http://resources0.news.com.au/images/2012/02/20/1226275/331552-jeremy-lin.jpg"
15+
"http://www.splicetoday.com/vault/posts/0003/2771/Five-things-you-didnt-know-about-Jeremy-Lin-T310FDNC-x-large_large.jpg?1329407309"
16+
"http://pacejmiller.com/wp-content/uploads/2012/02/021412_jeremy_lin_400.jpg"
17+
18+
]
19+
20+
module.exports = (robot) ->
21+
robot.hear /(linsanity|linspire)/i, (msg) ->
22+
msg.send msg.random images

src/scripts/mtg.coffee

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Insert Pictures of Magic: The Gathering Cards
3+
#
4+
# cast <card name> - a picture of the named magic card
5+
6+
querystring = require 'querystring';
7+
8+
module.exports = (robot) ->
9+
robot.respond /cast (.+)/i, (msg) ->
10+
url = "http://gatherer.wizards.com/Handlers/Image.ashx"
11+
card = msg.match[1] || "Dismal%20Failure"
12+
query = { type: "card", name: card }
13+
msg.send "#{url}?#{querystring.stringify(query)}#.jpg"

src/scripts/rollout.coffee

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Rollout REST API interface.
2+
#
3+
# Requires rollout_rest_api endpoint configured in the HUBOT_ROLLOUT_API_URL env var.
4+
#
5+
# Get rollout_rest_api here: https://github.com/jamesgolick/rollout_rest_api
6+
#
7+
# rollout list - Returns a list of available features.
8+
# rollout show <feature> - Shows the current rollout of `feature`.
9+
# rollout activate_user <feature> <user_id> - Activate `feature` for `user_id`.
10+
# rollout deactivate_user <feature> <user_id> - Deactivate `feature` for `user_id`.
11+
# rollout activate_group <feature> <group> - Activate `feature` for `group_id`.
12+
# rollout deactivate_group <feature> <group> - Deactivate `feature` for `group_id`.
13+
# rollout activate_percentage <feature> <percentage> - Activate `feature` for `percentage`% of users.
14+
# rollout deactivate <feature> - Deactivate `feature` all users.
15+
16+
endpoint = process.env.HUBOT_ROLLOUT_API_URL + '/'
17+
18+
show = (msg, feature) ->
19+
msg.http(endpoint + feature + '.json').get() (err, res, body) ->
20+
msg.send body
21+
22+
module.exports = (robot) ->
23+
robot.respond /rollout list$/i, (msg) ->
24+
msg.http(endpoint + 'features.json').get() (err, res, body) ->
25+
json = JSON.parse(body)
26+
msg.send json.sort().join("\n")
27+
28+
robot.respond /rollout show (.*)/i, (msg) ->
29+
show(msg, msg.match[1])
30+
31+
robot.respond /rollout activate_user ([^\s]*) ([^\s]*)/i, (msg) ->
32+
msg.http(endpoint + msg.match[1] + '/users').query(user: msg.match[2]).put() (err, res, body) ->
33+
show(msg, msg.match[1])
34+
35+
robot.respond /rollout deactivate_user ([^\s]*) ([^\s]*)/i, (msg) ->
36+
msg.http(endpoint + msg.match[1] + '/users').query({user: msg.match[2]}).delete() (err, res, body) ->
37+
show(msg, msg.match[1])
38+
39+
robot.respond /rollout activate_group ([^\s]*) ([^\s]*)/i, (msg) ->
40+
msg.http(endpoint + msg.match[1] + '/groups').query(group: msg.match[2]).put() (err, res, body) ->
41+
show(msg, msg.match[1])
42+
43+
robot.respond /rollout deactivate_group ([^\s]*) ([^\s]*)/i, (msg) ->
44+
msg.http(endpoint + msg.match[1] + '/groups').query({group: msg.match[2]}).delete() (err, res, body) ->
45+
show(msg, msg.match[1])
46+
47+
robot.respond /rollout activate_percentage ([^\s]*) ([^\s]*)/i, (msg) ->
48+
msg.http(endpoint + msg.match[1] + '/percentage').query(percentage: msg.match[2]).put() (err, res, body) ->
49+
show(msg, msg.match[1])
50+
51+
robot.respond /rollout deactivate ([^\s]*)/i, (msg) ->
52+
msg.http(endpoint + msg.match[1]).delete() (err, res, body) ->
53+
msg.send("[DONE]")

src/scripts/shipit.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ squirrels = [
77
"http://img.skitch.com/20100714-d6q52xajfh4cimxr3888yb77ru.jpg",
88
"https://img.skitch.com/20111026-r2wsngtu4jftwxmsytdke6arwd.png",
99
"http://images.cheezburger.com/completestore/2011/11/2/aa83c0c4-2123-4bd3-8097-966c9461b30c.jpg",
10-
"http://images.cheezburger.com/completestore/2011/11/2/46e81db3-bead-4e2e-a157-8edd0339192f.jpg"
10+
"http://images.cheezburger.com/completestore/2011/11/2/46e81db3-bead-4e2e-a157-8edd0339192f.jpg",
11+
"http://28.media.tumblr.com/tumblr_lybw63nzPp1r5bvcto1_500.jpg"
1112
]
1213

1314
module.exports = (robot) ->

src/scripts/sigh.coffee

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# http://xkcd.com/1009/
2+
3+
module.exports = (robot) ->
4+
sigh_counter = 0
5+
6+
robot.hear /(^|\W)[s]+[i]+[g]+[h]+(\z|\W|$)/i, (msg) ->
7+
if sigh_counter == 3
8+
sigh_counter = 0
9+
msg.send "I work out"
10+
else
11+
sigh_counter += 1
12+
msg.send "Girl look at that body"

0 commit comments

Comments
 (0)