Last active
December 17, 2015 11:59
-
-
Save taiyoh/5606344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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