Add some customizations and fun things.

This commit is contained in:
2019-07-02 21:48:14 -04:00
parent 93a9cd8abf
commit e2fcb1248d
6 changed files with 265 additions and 0 deletions

24
scripts/dilbert.coffee Normal file
View File

@@ -0,0 +1,24 @@
# Description:
# Retrieve Dilbert comics for entertainment but not profit
#
# Commands:
# hubot dilbert me [YYYY-MM-DD] - retrieves Dilbert comic, defaults to today's
module.exports = (robot) ->
robot.hear /dilbert me\.? ?(.*)?/i, (msg) ->
url = 'https://dilbert.com'
if msg.match[1]?
comicDateRegexp = /\d\d\d\d-?\d\d-?\d\d/
if not comicDateRegexp.exec(msg.match[1])?
msg.send("I do not understand '#{msg.match[1]}' as a date.")
return
url = "#{url}/strip/#{msg.match[1]}"
msg.http(url)
.get() (err, res, body) ->
if err
msg.send "Sorry, I can't do that."
return
rx1 = /img-responsive.*>/
rx2 = /\/\/[^"]*/
img = rx2.exec(rx1.exec(body)).toString()
msg.send("https:#{img}.png")