Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request #30 from cflee/cleanup-scripts
Browse files Browse the repository at this point in the history
Cleanup scripts
  • Loading branch information
fonglh committed Jun 3, 2016
2 parents 07a9344 + 83bf03a commit a158f8d
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 28 deletions.
4 changes: 2 additions & 2 deletions external-scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"hubot-redis-brain",
"hubot-rules",
"hubot-shipit",
"hubot-spot",
"hubot-standup-alarm"
"hubot-standup-alarm",
"hubot-xkcd"
]
9 changes: 0 additions & 9 deletions hubot-scripts.json

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"hubot-scripts": "^2.0.0",
"hubot-shipit": "^0.2.0",
"hubot-slack": "^3.0.0",
"hubot-spot": "^1.0",
"hubot-standup-alarm": "0.0.7"
"hubot-standup-alarm": "0.0.7",
"hubot-xkcd": "0.0.3"
},
"engines": {
"node": "0.10.x"
Expand Down
51 changes: 51 additions & 0 deletions scripts/demolition-man.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Description:
# Watch your language!
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
#
# Author:
# whitman, jan0sch

module.exports = (robot) ->

words = [
'arsch',
'arschloch',
'arse',
'ass',
'bastard',
'bitch',
'bugger',
'bollocks',
'bullshit',
'cock',
'cunt',
'damn',
'damnit',
'depp',
'dick',
'douche',
'fag',
'fotze',
'fuck',
'fucked',
'fucking',
'kacke',
'piss',
'pisse',
'scheisse',
'schlampe',
'shit',
'wank',
'wichser'
]
regex = new RegExp('(?:^|\\s)(' + words.join('|') + ')(?:\\s|\\.|\\?|!|$)', 'i');

robot.hear regex, (msg) ->
msg.send 'You have been fined one credit for a violation of the verbal morality statute.'
62 changes: 62 additions & 0 deletions scripts/gorbypuff.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Description:
# Gorbypuff Thunderstone
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# gorby - Display a picture of everyone's favorite flat-faced cat
#
# Author:
# bradly

gorbies = [
"http://24.media.tumblr.com/ded6b610059bac9203432ae1999fb439/tumblr_mix1ntHwN21rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/4eaabf5111c8444e68208adaa22c1c3a/tumblr_mewmgwxzZA1rt6kj7o1_1280.jpg",
"http://24.media.tumblr.com/tumblr_me3ubx13ck1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_md5v15WAWI1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_mcbxaz9w7T1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_mbqotcRr4j1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_m99wdgHcNN1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_m94zjtC4sy1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_m8cju4aFeS1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m7a3unqPjr1rt6kj7o1_1280.jpg",
"http://25.media.tumblr.com/tumblr_m6lev83Gak1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m6leq7NrsY1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m5vy9hfcTs1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m5g0bmkl601rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m5g0ab3EiH1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m51suk3wfS1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m50tx5IWhJ1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m4q48mVFXj1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m4hxmurzlL1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m4hxioPUln1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m4gqg94kSA1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m4c9ncT0LM1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m44m5g6m001rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m3v8keZVhR1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m3k8rvS6Uq1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m3k88eKJQf1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m3elppeyqa1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m3ekqyJ1iy1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m35xkkGbKO1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m305ndXRNH1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m2v55jdLgV1rt6kj7o1_500.png",
"http://25.media.tumblr.com/tumblr_m2ro01h07O1rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m2olbl9Uw61rt6kj7o1_1280.png",
"http://25.media.tumblr.com/tumblr_m2n4grjjN51rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m2j8mhAuMm1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m2i8utX5Qv1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m2i85ws1561rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m288synRIj1rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m21kfe7zir1rt6kj7o1_400.png",
"http://25.media.tumblr.com/tumblr_m21hprOGO71rt6kj7o1_1280.png",
"http://24.media.tumblr.com/tumblr_m21gc84uY21rt6kj7o1_1280.png"
]

module.exports = (robot) ->
robot.hear /gorby|puff|thunderhorse/i, (msg) ->
msg.send msg.random gorbies
54 changes: 54 additions & 0 deletions scripts/grumpycat.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Description:
# Load a random Grumpy Cat from an array of images.
# Based on pugme.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot grumpycat me - Receive a Grumpy Cat
# hubot grumpycat bomb N - get N Grumpy Cats
#
# Author:
# trey

cats = [
"http://mlkshk.com/r/M6EO.gif", # rabbit in a hat
"http://mlkshk.com/r/M17S.gif", # dress
"http://mlkshk.com/r/M15O.gif", # le mis
"http://mlkshk.com/r/M01A.gif", # cartoons
"http://mlkshk.com/r/LZ7U.gif", # fuck this
"http://mlkshk.com/r/LXP2.gif", # grumpy tardar sauce
"http://mlkshk.com/r/LWNG.gif", # grandma got run over
"http://mlkshk.com/r/LVVR.gif", # double deal with it
"http://mlkshk.com/r/LV0S.gif", # mural
"http://mlkshk.com/r/LUYE.gif", # stahp
"http://mlkshk.com/r/LUO2.gif", # good
"http://mlkshk.com/r/LS6R.gif", # shut the fuck up
"http://mlkshk.com/r/LSWD.gif", # Tardar Bonepart
"http://mlkshk.com/r/LPCN.gif", # drawing
"http://mlkshk.com/r/LLVD.gif", # terrible time of the year
"http://mlkshk.com/r/LKTG.gif", # Citizen Kane
"http://mlkshk.com/r/LEF8.gif", # emotions
"http://mlkshk.com/r/LEFR.gif", # skate deck
"http://mlkshk.com/r/L337.gif", # look askance
"http://mlkshk.com/r/KV8K.gif", # sitting
"http://mlkshk.com/r/KU1S.gif", # 3 grump moon
"http://mlkshk.com/r/KRBA.gif", # rabbit painting
"http://mlkshk.com/r/KL19.gif" # lying on the ground
]

module.exports = (robot) ->
robot.respond /grumpycat me/i, (msg) ->
msg.send cats[Math.floor(Math.random()*cats.length)]

robot.respond /grumpycat bomb( (\d+))?/i, (msg) ->
count = msg.match[2] || 5
for i in [1..count] by 1
msg.send cats[Math.floor(Math.random()*cats.length)]

robot.respond /how many grumpycats are there/i, (msg) ->
msg.send "There are #{cats.length} grumpycats."
10 changes: 5 additions & 5 deletions scripts/historian.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
URL = process.env.HUBOT_HISTORIAN_URL || "http://192.168.100.242:56400"

module.exports = (robot) ->
robot.hear /.*/i, (msg) ->
log = "#{new Date()} | #{msg.message.room} | #{msg.message.user.name} | #{msg.message}"
robot.http(URL)
.header('Content-Type', 'application/text')
.post(log)
# robot.hear /.*/i, (msg) ->
# log = "#{new Date()} | #{msg.message.room} | #{msg.message.user.name} | #{msg.message}"
# robot.http(URL)
# .header('Content-Type', 'application/text')
# .post(log)
33 changes: 33 additions & 0 deletions scripts/ruby.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Description:
# Evaluate one line of Ruby script
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot ruby|rb <script> - Evaluate one line of Ruby script
#
# Author:
# jingweno

module.exports = (robot) ->
robot.respond /(ruby|rb)\s+(.*)/i, (msg)->
script = msg.match[2]

msg.http("http://tryruby.org/levels/1/challenges/0")
.query("cmd": script)
.headers("Content-Length": "0")
.put() (err, res, body) ->
switch res.statusCode
when 200
result = JSON.parse(body)

if result.success
msg.reply result.output
else
msg.reply result.result
else
msg.reply "Unable to evaluate script: #{script}. Request returned with the status code: #{res.statusCode}"
22 changes: 22 additions & 0 deletions scripts/ruby_rules.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Description:
# Make sure that hubot shares the ruby rules.
#
# Commands:
# hubot the ruby rules - Make hubot explain how to write practical ruby.
#
# Notes:
# These rules were provided by Sandy Metz in the Ruby Rouges podcast:
# http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/

rubyRules = [
"1. Your class can be no longer than 100 lines of code.",
"2. Your methods can be no longer than 5 lines of code.",
"3. You can pass no more than 4 parameters and you can’t just make it one big hash.",
"4. In your rails controller, you can only instantiate 1 object to do whatever it is that needs to be done.",
"5. Your rails view can only know about 1 instance variable",
"6. You can break these rules if you can explain to your pair or in your pull request why it makes sense."
]

module.exports = (robot) ->
robot.respond /(what are )?the ruby (rules|laws)/i, (msg) ->
msg.send rubyRules.join('\n')
26 changes: 26 additions & 0 deletions scripts/rubygems.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Description:
# Find a rubygem from rubygems.org
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot there's a gem for <that> - Returns a link to a gem on rubygems.org
#
# Author:
# sferik

module.exports = (robot) ->
robot.respond /there's a gem for (.*)/i, (msg) ->
search = msg.match[1]
msg.http('https://rubygems.org/api/v1/search.json')
.query(query: search)
.get() (err, res, body) ->
results = JSON.parse(body)
gems=[]
for result in results[0..4]
gems.push "#{result.name}: https://rubygems.org/gems/#{result.name}"
if gems.length>0 then msg.send gems.join('\n') else msg.send "Actually, there isn't a gem for that!"
10 changes: 0 additions & 10 deletions scripts/waffles.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@

waffleTypes = ['plain', 'kaya', 'butter', 'peanut', 'redbean', 'chocolate', 'blueberry', 'cheese']
waffleReminders = [5, 3, 1] # minutes till timeout
URL = process.env.HUBOT_SPOT_URL || "http://localhost:5051"
TIMEOUT = 15 * 60 * 1000

# Send a request to spot
spotRequest = (message, path, action, options, callback) ->
message.http("#{URL}#{path}")
.query(options)[action]() (err, res, body) ->
callback(err,res,body)

module.exports = (robot) ->
# produces a summary of current orders
summaries = () ->
Expand Down Expand Up @@ -77,9 +70,6 @@ module.exports = (robot) ->
if robot.brain.get('waffleTime') == date
msg.send '*No more orders!* ' + summaries() + "\nCall *6469 3360* to order."
), TIMEOUT
params = {what: 'Taking waffle orders'}
spotRequest msg, '/say', 'put', params, (err, res, body) ->
null

robot.hear new RegExp("^(#{waffleTypes.join('|')})$", 'i'), (msg) ->
if isOrderActive()
Expand Down

0 comments on commit a158f8d

Please sign in to comment.