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

Achewood improvements #1114

Merged
merged 5 commits into from
Sep 6, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/scripts/achewood.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# hubot achewood - A random Achewood comic
# hubot achewood current - The most recent Achewood comic
# hubot achewood <date> - Achewood comic from <date> - mm/dd/yyyy format
# hubot achewood <keyword> - Achewood comic for keyword
# hubot saddest thing - The saddest thing, according to Lie Bot
#
# Author:
Expand All @@ -36,16 +37,22 @@ module.exports = (robot) ->
msg.send "http://achewood.com" + comic.src + "#.png"
msg.send comic.title

robot.respond /achewood\s?((0[1-9]|1[0-2]).(0[1-9]|[1-2][0-9]|3[0-1]).(20\d{2})$|current)?/i, (msg) ->
if msg.match[1] == undefined
robot.respond /achewood\s?((?:0[1-9]|1[0-2]).?(?:0[1-9]|[1-2][0-9]|3[0-1]).?(?:20\d{2})$|.*)?/i, (msg) ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, I guess I broke this entirely

COFFEESCRIPT!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg = msg.match[1]
if arg == undefined
msg.http("http://www.ohnorobot.com/random.pl?comic=636")
.get() (err, res, body) ->
fetchAchewood(msg, res.headers['location'])
else if msg.match[1] == "current"
else if arg == "current"
fetchAchewood(msg, "http://achewood.com")
else
date = "#{msg.match[2]}#{msg.match[3]}#{msg.match[4]}"
else if arg.match /\d{2}.?\d{2}.?\d{4}/
date = arg.replace /\D/g, ''
fetchAchewood(msg, withDate(date))
else
query = arg
msg.http("http://www.ohnorobot.com/index.pl?comic=636&lucky=1&s=#{query}")
.get() (err, res, body) ->
fetchAchewood(msg, res.headers['location'])

robot.respond /.*saddest thing\?*/i, (msg) ->
saddest = msg.random ["06022003", "11052001", "09052006", "07302007"]
Expand Down