Skip to content

Commit

Permalink
Merge pull request #36 from ScrappyAcademy/friday_code_fun
Browse files Browse the repository at this point in the history
Add a play patch for campfire.
  • Loading branch information
cupakromer committed Feb 26, 2013
2 parents 74c8712 + 3200a34 commit 4ae0699
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 0 deletions.
46 changes: 46 additions & 0 deletions scripts/add_play_patch.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Description:
# Patching the Robot class to allow for easier playing of sounds in Campfire
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# None
#
# Author:
# cupakromer
Adapter = require 'hubot/src/adapter'
Robot = require 'hubot/src/robot'

# For actual patch to source will need to add
#Adapter::play = (user, sound) -> #no-op
#Campfire::play
#Shell::play

Robot.Response::play = (sound) ->
@robot.adapter.play @message.user, sound

# To be deleted after hubot source is patched
module.exports = (robot) ->
robot.logger.debug "In Play Patch"
robot.logger.debug "Play defined? #{robot.adapter.play?}"
unless robot.adapter.play?
robot.logger.debug "Bot defined? #{robot.adapter.bot?}"
robot.logger.debug "Room defined? #{robot.adapter.bot?.Room?}"
if robot.adapter.bot?.Room?
robot.logger.info "Adding 'play' Campfire patch."
robot.adapter.play = (user, sound) ->
# Campfire adapter object context
if sound.length > 0
@bot.Room(user.room).sound sound, (err, data) =>
# Campfire adapter object context
@robot.logger.error "Campfire error: #{err}" if err?
@send user, "/play #{sound}"
else
robot.logger.info "Adding 'play' standard patch"
robot.adapter.play = (user, sound) ->
if sound.length > 0
@send user, "/play #{sound}"
19 changes: 19 additions & 0 deletions scripts/emoji-secret.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Description:
# Whenever someone posts a link to the emoji-cheat-sheet website
# the old 8-bit game secret sound will play.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# emoji-cheat-sheet.com
#
# Author:
# cupakromer

module.exports = (robot) ->
robot.hear /emoji-cheat-sheet\.com/i, (msg) ->
msg.play 'secret'
46 changes: 46 additions & 0 deletions scripts/facepalm.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Description:
# Post an actual facepalm whenever some mentions it.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# facepalm
#
# Author:
# cupakromer

facepalms = [
"http://media.tumblr.com/7b32e336b10589b678c5fafda8a4cace/tumblr_inline_mi2kfhtKhY1qz4rgp.gif",
"http://images2.wikia.nocookie.net/__cb20121110220608/adventuretimewithfinnandjake/images/e/e6/Facepalm100000000.gif",
"http://images.wikia.com/glee/images/a/a7/Draco-malfoy-facepalm.gif",
"http://images.wikia.com/theamazingworldofgumball/images/8/8d/1260528522_itcrowd-facepalm.gif",
"http://static.divbyzero.nl/facepalm/doublefacepalm.jpg",
"http://images4.alphacoders.com/146/146716.jpg",
"http://fc00.deviantart.net/fs71/i/2011/184/b/9/triple_facepalm_by_spottedheart98464-d3kuyp3.png",
"http://fc03.deviantart.net/fs22/f/2009/242/9/2/Sigh_Facepalm_____by_Ghost1334652.jpg",
"http://images4.fanpop.com/image/photos/19800000/-Facepalm-lunashay-19892493-750-600.jpg",
"http://www.theparentingdad.com/wp-content/uploads/2012/08/baby-facepalm.jpg",
"http://images5.fanpop.com/image/photos/30300000/Godzilla-Facepalm-godzilla-30354011-640-387.jpg",
"http://fc02.deviantart.net/fs71/i/2013/018/e/e/inner_facepalm_demotivational_by_senkkari-d5rdzlu.png",
"http://fc05.deviantart.net/fs50/f/2009/317/a/2/Peach_Facepalm_by_Finalsmasher.jpg",
"http://fc09.deviantart.net/fs50/f/2009/330/2/a/Facepalm_by_iceman_3567.jpg",
"http://fc09.deviantart.net/fs71/f/2012/067/d/2/bunny_facepalm_by_shlj23-d4s3yaj.jpg",
"http://static.fjcdn.com/pictures/Super+facepalm_db95e1_3420603.jpg",
"http://likegif.com/wp-content/uploads/2012/10/facepalm-gif-33.gif",
"http://25.media.tumblr.com/tumblr_m0f3b7mqFY1qh2o7zo1_500.gif",
"http://saxsociety.com/forum/avatars/facepalm-text-picture-8110.jpg",
"http://onwardstate.com/wp-content/uploads/2010/01/Lion-facepalm.jpg",
"http://cat.facepalm.de/images/facepalm.jpg",
"http://i.qkme.me/35623p.jpg",
"http://assets.motivationalgenerator.com/hashed_silo_content/638/92b/d10/resized/vegeta-facepalm-because-your-fail-is-out-of-this-world-2c1d32.jpg",
"http://i895.photobucket.com/albums/ac159/GIFsforhire/Movies-Shows/Doctor%20Who/FACEPALM.gif",
"http://i268.photobucket.com/albums/jj37/moochie_bean/Gif%20Stock/facepalm.gif"
]

module.exports = (robot) ->
robot.hear /facepalm/i, (msg) ->
msg.send msg.random facepalms
33 changes: 33 additions & 0 deletions scripts/lonely.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Description:
# Because let's be honest, this was your reaction the first time too
#
# Dependencies:
# None
#
# Configuration:
# Needs Redis
#
# Commands:
# Talk to yourself when in the chat room alone
#
# Author:
# cupakromer

module.exports = (robot) ->
robot.brain.active = robot.brain.active or [ ]

userIsAlone = ->
1 == robot.brain.active.length

# Register users when they arrive
robot.enter (response) ->
robot.brain.active.push(response.message.user.id)

# Remove users when they leave
robot.leave (response) ->
robot.brain.active = robot.brain.active.filter (id) ->
response.message.user.id != id

robot.hear /./i, (msg) ->
if userIsAlone() and 1 == Math.floor(Math.random() * 2)
msg.play 'crickets'
36 changes: 36 additions & 0 deletions scripts/trollin.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Description:
# Hubot will troll people randomly (even itself)
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# Nothing just talk
#
# Author:
# cupakromer

trolls = [
":trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface: :trollface:",
"http://images5.fanpop.com/image/photos/28500000/They-see-me-trollin-They-hatin-chocoluvr101-28557270-300-333.png",
"http://img1.joyreactor.com/pics/post/demotivation-posters-auto-344251.jpeg",
"http://cdn.memegenerator.net/instances/400x/24985000.jpg",
"http://ct.fra.bz/ol/fz/sw/i51/5/5/4/frabz-They-see-me-trollin-they-hatin-895e35.jpg",
"http://rlv.zcache.co.uk/they_see_me_trollin_they_hatin_speckcase-p176089345251326001en8cx_216.jpg",
"https://i.chzbgr.com/maxW500/6586469376/h8B70ECD1/",
"http://1.bp.blogspot.com/_19PO40AlFUY/TGT0iHPOysI/AAAAAAAAAKY/KmIttVHh1mI/s1600/singlelobsterfuck.jpg",
"http://i190.photobucket.com/albums/z316/ebonobelisk/troll1.jpg",
"http://fc05.deviantart.net/fs71/f/2011/167/9/1/sir_troll_cat_was_here_by_jesf-d3j43q2.jpg"
]

troll_sounds = ["trololo", "nyan", "yodel"]

module.exports = (robot) ->
one_in = (upper_limit) -> 1 == Math.floor(Math.random() * upper_limit)

robot.hear /./i, (msg) ->
msg.send msg.random trolls if one_in(100)
msg.play msg.random(troll_sounds) if one_in(40)

0 comments on commit 4ae0699

Please sign in to comment.