Avoid redirects and change error message

This commit is contained in:
rnhmjoj 2015-09-26 21:02:10 +02:00
parent e293bb2000
commit 66f6e29e87

View File

@ -11,13 +11,15 @@
# Enrico Fasoli (fazo96)
module.exports = (robot) ->
escape = (str) -> (str.replace /\ /g, '_').replace /-/g, '--'
escape = (str) -> (str.replace /-/g, '--').replace /\ /g, '-'
usage = 'non si usa così: prova a chiedermi "asjon help meme" per
sapere sapere come funziona il comando'
robot.respond /meme (.+)/i, (res) ->
text = res.match[1]
if(text.split(',').length != 3)
res.send 'richiesta malformata: prova a chiedermi "asjon help meme" per sapere sapere come funziona il comando'
else
meme = (escape i.trim() for i in text.split ',').join '/'
url = 'http://memegen.link/' + meme + '.jpg'
res.send url
return res.send usage if text.split(',').length != 3
meme = (escape i.trim() for i in text.split ',').join '/'
url = 'http://memegen.link/' + meme + '.jpg'
res.send url