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

Commit

Permalink
GIF insanity
Browse files Browse the repository at this point in the history
  • Loading branch information
iangreenleaf committed Dec 20, 2012
1 parent 9870aee commit edb4d78
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 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.