Skip to content

Instantly share code, notes, and snippets.

@taiyoh
Last active Dec 17, 2015
Embed
What would you like to do?
# 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