This repository was archived by the owner on Oct 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds config and improves time handling
- Loading branch information
Matthew Kowalski
committed
Mar 29, 2015
1 parent
8fdd755
commit ee04762
Showing
4 changed files
with
24 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
node_modules | ||
ngrok |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"curly": true, | ||
"esnext": true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
var ack = require('ac-koa').require('hipchat'), | ||
moment = require('moment'), | ||
var ack = require('ac-koa'), | ||
hipchat = ack.require('hipchat'), | ||
moment = require('moment-timezone'), | ||
pkg = require('./package.json'), | ||
app = ack(pkg); | ||
|
||
var addon = app | ||
.addon() | ||
moment.tz.setDefault(pkg.settings.timezone); | ||
|
||
var addon = app.addon() | ||
.hipchat() | ||
.allowRoom(true) | ||
.scopes('send_notification'); | ||
|
||
addon.webhook('room_message', /^\/till$/, function*() { | ||
var target = moment().zone('-05:00').hour(16).minute(0).second(0).utc(), | ||
now = moment.utc(), | ||
diff = target.diff(now); | ||
var now = moment(); | ||
var target = moment() | ||
.hour(pkg.settings.time) | ||
.minute(0) | ||
.second(0); | ||
|
||
if (now.isAfter(target)) { | ||
target.add(1, 'd'); | ||
} | ||
|
||
yield this.roomClient.sendNotification('You shall imbibe in ' + moment.duration(diff, "milliseconds").humanize()); | ||
yield this.roomClient.sendNotification('You shall imbibe in ' + target.from(now, true)); | ||
}); | ||
|
||
app.listen(); |
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