Skip to content

Commit

Permalink
Merge pull request github#191 from gshutler/meme-dimensions
Browse files Browse the repository at this point in the history
Added the ability to set dimensions for the generated memes
  • Loading branch information
tombell committed Dec 3, 2011
2 parents 13baa7d + 75c5ac3 commit bece9f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/scripts/meme_generator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = (robot) ->
memeGenerator = (msg, generatorID, imageID, text0, text1, callback) ->
username = process.env.HUBOT_MEMEGEN_USERNAME
password = process.env.HUBOT_MEMEGEN_PASSWORD
preferredDimensions = process.env.HUBOT_MEMEGEN_DIMENSIONS

unless username
msg.send "MemeGenerator username isn't set. Sign up at http://memegenerator.net"
Expand All @@ -77,12 +78,16 @@ memeGenerator = (msg, generatorID, imageID, text0, text1, callback) ->
text1: text1
.get() (err, res, body) ->
result = JSON.parse(body)['result']
if result? and result['instanceUrl']? and result['instanceImageUrl']?
if result? and result['instanceUrl']? and result['instanceImageUrl']? and result['instanceID']?
instanceID = result['instanceID']
instanceURL = result['instanceUrl']
img = result['instanceImageUrl']
msg.http(instanceURL).get() (err, res, body) ->
# Need to hit instanceURL so that image gets generated
callback "http://memegenerator.net#{img}"
if preferredDimensions?
callback "http://images.memegenerator.net/instances/#{preferredDimensions}/#{instanceID}.jpg"
else
callback "http://memegenerator.net#{img}"
else
msg.reply "Sorry, I couldn't generate that image."

Expand Down

0 comments on commit bece9f5

Please sign in to comment.