This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9870aee
commit edb4d78
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |