Skip to content

Instantly share code, notes, and snippets.

@taiyoh
Last active December 17, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taiyoh/5606344 to your computer and use it in GitHub Desktop.
Save taiyoh/5606344 to your computer and use it in GitHub Desktop.
# Description:
# 話しかけたら反応します.
#
# Commands:
# hubot 〜〜〜 - ask him!
#
# Notes:
# DON'T DELETE THIS SCRIPT!
rules = [
"そうっスね('-'*)",
"うんうん('-'*)"
]
module.exports = (robot) ->
robot.respond /(.+)$/i, (msg) ->
user = msg.message.user.name
match = msg.message.text.match /((\d{1,2}):(\d\d)) (.+)$/
if match
date = match[1]
d = new Date
d.setHours parseInt(match[2], 10)
d.setMinutes parseInt(match[3], 10)
diff = d.getTime() - (new Date).getTime()
if (diff > 0)
text = match[4]
setTimeout(() ->
msg.send "#{user}: #{date}だよー。 \"#{text}\" わすれないでねー('-'*)"
, diff)
msg.send "はーい('-'*)"
else
reply = rules[Math.floor((Math.random() * rules.length))]
msg.send "#{user}: #{reply}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment