Skip to content

Commit

Permalink
Es6 rewrite (#13)
Browse files Browse the repository at this point in the history
* Rewriting _everything_
* Adding travis yml file
  • Loading branch information
shaunburdick authored Sep 8, 2016
1 parent 04c82f7 commit 60e1665
Show file tree
Hide file tree
Showing 43 changed files with 918 additions and 4,712 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
npm-debug.log
config.js
/config.js
doc/*
/coverage/
/.nyc_output/
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "5"
- "6"
after_success: npm run coverage
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM node:latest
FROM rezzza/docker-node:latest

MAINTAINER Shaun Burdick <[email protected]>

RUN apk add -U tzdata

ENV NODE_ENV=production \
SLACK_TOKEN=xoxb-foo \
SLACK_AUTO_RECONNECT=true \
Expand All @@ -13,4 +15,4 @@ WORKDIR /usr/src/myapp

RUN ["npm", "install"]

CMD ["npm", "start"]
CMD ["npm", "start"]
16 changes: 16 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
GNU GENERAL PUBLIC LICENSE

Copyright (c) 2016 Shaun Burdick

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bot: npm start
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Out of Office Bot for Slack
===========================

[![Build Status](https://travis-ci.org/shaunburdick/slack-ooo.svg?branch=master)](https://travis-ci.org/shaunburdick/slack-ooo) [![Docker Pulls](https://img.shields.io/docker/pulls/shaunburdick/slack-ooo.svg?maxAge=2592000)](https://hub.docker.com/r/shaunburdick/slack-ooo/)
[![Coverage Status](https://coveralls.io/repos/github/shaunburdick/slack-ooo/badge.svg?branch=update-dep)](https://coveralls.io/github/shaunburdick/slack-ooo?branch=update-dep) [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-round)](https://github.com/Flet/semistandard)

[![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/shaunburdick/slack-ooo) [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)

This bot can be told when you are out of the office. It will then listen to conversations and tell users that mention you that you are not around.

If you want a personal OoO bot that acts as you, check out [shaunburdick/slack-ooo-personal](https://github.com/shaunburdick/slack-ooo-personal)!
**If you want a personal OoO bot that acts as you, check out [shaunburdick/slack-ooo-personal](https://github.com/shaunburdick/slack-ooo-personal)!**

##Usage
To use this bot, you start a conversation with it:
Expand Down Expand Up @@ -51,7 +56,7 @@ I will be out until next week
## Install
1. Clone this [repository](https://github.com/shaunburdick/slack-ooo.git)
2. `npm install`
3. Copy `./release/js/config.default.js` to `./release/js/config.js` and fill it out
3. Copy `config.default.js` to `config.js` and fill it out
4. `npm start`

## Test
Expand All @@ -70,7 +75,6 @@ You can set the configuration of the bot by using environment variables.

- *SLACK_TOKEN*=xoxb-foo, Your Slack Token
- *SLACK_AUTO_RECONNECT*=true, Reconnect on disconnect
- *SLACK_AUTO_MARK*=true, Mark messages as read

Set them using the `-e` flag while running docker:

Expand All @@ -79,3 +83,11 @@ docker run -it \
-e SLACK_TOKEN=xobo-blarty-blar-blar \
shaunburdick/slack-ooo:latest
```

## Contributing
1. Create a new branch, please don't work in master directly.
2. Add failing tests for the change you want to make (if appliciable). Run `npm test` to see the tests fail.
3. Fix stuff.
4. Run `npm test` to see if the tests pass. Repeat steps 2-4 until done.
5. Update the documentation to reflect any changes.
6. Push to your fork and submit a pull request.
30 changes: 30 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Slack OOO",
"description": "Slack Out of Office Message Responder",
"keywords": [
"slack",
"bot",
"ooo",
"out of office"
],
"repository": "https://github.com/shaunburdick/slack-ooo",
"env": {
"SLACK_TOKEN": {
"description": "Your Slack token"
},
"SLACK_AUTO_RECONNECT": {
"description": "Reconnect on disconnect",
"value": "true"
},
"NODE_ENV": {
"value": "production"
}
},
"image": "heroku/nodejs",
"formation": {
"bot": {
"quantity": 1,
"size": "free"
}
}
}
7 changes: 7 additions & 0 deletions config.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var config = {
slack: {
token: 'xoxb-foo',
autoReconnect: true
}
};
module.exports = config;
6 changes: 6 additions & 0 deletions docker-cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bot:
image: shaunburdick/slack-ooo
restart: on-failure
environment:
SLACK_TOKEN: 'xoxb-foo'
SLACK_AUTO_RECONNECT: true
41 changes: 0 additions & 41 deletions gulpfile.js

This file was deleted.

35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

const logger = require('./lib/logger')();
const redact = require('redact-object');
const Bot = require('./lib/bot');
const Config = require('./lib/config');

let config;

/**
* Load config
*/
const rawConfig = (() => {
let retVal;
try {
retVal = require('./config');
} catch (exception) {
retVal = require('./config.default');
}

return retVal;
})();

try {
config = Config.parse(rawConfig);
} catch (error) {
logger.error('Could not parse config', error);
process.exit(1);
}

logger.info('Using the following configuration:', redact(config, ['token']));

logger.info('Starting Bot...');
const bot = new Bot(config);
bot.start();
Loading

0 comments on commit 60e1665

Please sign in to comment.