Use brain 'loaded' event in remind.coffee
- Removes hacky setTimeout method
This commit is contained in:
Родитель
b835bf1b86
Коммит
7ed2430eba
|
@ -9,11 +9,11 @@ class Reminders
|
|||
@cache = []
|
||||
@current_timeout = null
|
||||
|
||||
loadReminders = =>
|
||||
@robot.brain.on 'loaded', =>
|
||||
if @robot.brain.data.reminders
|
||||
@cache = @robot.brain.data.reminders
|
||||
@queue()
|
||||
setTimeout loadReminders, 5000 # Hacky until there's some kind of 'loaded' notification
|
||||
loadReminders = =>
|
||||
|
||||
add: (reminder) ->
|
||||
@cache.push reminder
|
||||
|
@ -58,7 +58,7 @@ class Reminder
|
|||
seconds:
|
||||
value: 0
|
||||
regex: "seconds?|secs?"
|
||||
|
||||
|
||||
for period of periods
|
||||
pattern = new RegExp('^.*?([\\d\\.]+)\\s*(?:(?:' + periods[period].regex + ')).*$', 'i')
|
||||
matches = pattern.exec(@time)
|
||||
|
@ -81,4 +81,3 @@ module.exports = (robot) ->
|
|||
reminder = new Reminder msg.message.user, time, action
|
||||
reminders.add reminder
|
||||
msg.send 'I\'ll remind you to ' + action + ' on ' + reminder.dueDate()
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче