Skip to content
This repository was archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
adds config and improves time handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Kowalski committed Mar 29, 2015
1 parent 8fdd755 commit ee04762
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
ngrok
1 change: 0 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"curly": true,
"esnext": true
}
24 changes: 16 additions & 8 deletions app.js
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();
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "bourbot",
"displayName": "Bourbot",
"version": "0.0.1",
"description": "Tells you how long until you can enjoy some delicious libations",
"description": "HipChat bot that tells you how long until you can enjoy some delicious libations",
"author": "Matthew Kowalski",
"scripts": {
"start": "node --harmony app.js",
"tunnel": "./ngrok 3000"
"tunnel": "lt --port 3000"
},
"development": {
"port": 3000
Expand All @@ -16,13 +17,17 @@
"port": "$PORT"
},
"settings": {
"partyTime": "16"
"timezone": "America/Chicago",
"time": 16
},
"license": "MIT",
"dependencies": {
"ac-koa": "^0.2.6",
"ac-koa-hipchat": "^0.2.16",
"moment": "^2.9.0",
"moment-timezone": "^0.3.1"
},
"devDependencies": {
"localtunnel": "^1.5.0"
}
}

0 comments on commit ee04762

Please sign in to comment.