Last active
December 18, 2015 18:49
-
-
Save saihoooooooo/5828308 to your computer and use it in GitHub Desktop.
Message timer for hubot.
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: | |
# alarm wo narase!! | |
# | |
# Commands: | |
# hubot timer <int> [<text>] - <int> byou go ni <text> wo hyouji | |
# hubot alarm 12:34 [<text>] - 12:34 ni <text> wo hyouji | |
module.exports = (robot) -> | |
robot.respond /timer (\d+) ?(.+)?/i, (msg) -> | |
time = msg.match[1] * 1000 | |
text = msg.match[2] ? 'ジリリリリリリリ' | |
setTimeout -> | |
msg.send text | |
, time | |
robot.respond /alarm (\d{2}:\d{2}) ?(.+)?/i, (msg) -> | |
time = msg.match[1] | |
text = (msg.match[2] ? 'ジリリリリリリリ') + ' > ' + msg.message.user.name | |
msg.send '受け付けました' | |
timer = setInterval -> | |
date = new Date() | |
h = date.getHours() | |
h = '0' + h if h < 10 | |
m = date.getMinutes() | |
m = '0' + m if m < 10 | |
console.log h + ':' +m | |
if time == (h + ':' +m) | |
msg.send text if time == (h + ':' +m) | |
clearTimeout timer | |
, 60000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment