Permalink
Browse files

GIF insanity

  • Loading branch information...
1 parent 9870aee commit edb4d78683c56bc571cd12d64af1ec796d8536c2 @iangreenleaf iangreenleaf committed Dec 20, 2012
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/scripts/gifsanity.coffee
@@ -0,0 +1,37 @@
+# Description:
+# Pulls GIFs from various insane tumblrs
+#
+# Dependencies:
+# "tumblrbot": "0.1.0"
+#
+# Configuration:
+# HUBOT_TUMBLR_API_TOKEN
+#
+# Commands:
+# hubot gif me - Returns a random gif from a random blog
+# hubot food mosh - Returns a random gif from foodmosh.tumblr.com
+# hubot fluxmachine - Returns a random gif from fluxmachine.tumblr.com
+# hubot nic cage me - Returns a random gif from gifolas-cage.tumblr.com
+#
+# Author:
+# iangreenleaf
+
+tumblr = require "tumblrbot"
+SOURCES = {
+ "foodmosh.tumblr.com": /(food)( mosh)?( me)?/i
+ "fluxmachine.tumblr.com": /(flux)( ?machine)?( me)?/i
+ "gifolas-cage.tumblr.com": /(nic )?cage( me)?/i
+}
+
+getGif = (blog, msg) ->
+ tumblr.photos(blog).random (post) ->
+ msg.send post.photos[0].original_size.url
+
+module.exports = (robot) ->
+ robot.respond /gif(sanity)?( me)?/i, (msg) ->
+ blog = msg.random Object.keys(SOURCES)
+ getGif blog, msg
+
+ for blog,pattern of SOURCES
+ robot.respond pattern, (msg) ->
+ getGif blog, msg

0 comments on commit edb4d78

Please sign in to comment.