Skip to content

Commit

Permalink
Store the token in a separate file which is never checked in.
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieHess committed Jul 23, 2015
1 parent c89c0cc commit 6e403de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
output/
token.txt
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ A bot that turns Slack into a legitimate Texas Hold'em client. Start a game in a

### Getting Started
1. Create a new [bot integration](https://my.slack.com/services/new/bot)
1. Add your API token to `main.js`
1. Paste the API token from your integration into `main.js` _OR_
1. Create a `token.txt` file and paste your API token there
1. `npm install`
1. `node src/main.js`
1. To start a game, `@<your_bot_name>: Deal`
Expand Down
6 changes: 1 addition & 5 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ class Bot {
//
// token - An API token from the bot integration
constructor(token) {
if (token === 'YOUR-TOKEN-GOES-HERE') {
throw new Error('Use a valid API token!');
} else {
this.slack = new Slack(token, true, true);
}
this.slack = new Slack(token, true, true);
}

// Public: Brings this bot online and starts handling messages sent to it.
Expand Down
10 changes: 9 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
require('babel/register');

try {
var fs = require('fs');
var token = fs.readFileSync('token.txt', 'utf8').trim();
} catch (error) {
console.log("Your API token should be placed in a 'token.txt' file, which is missing.");
return;
}

var Bot = require('./bot');
var bot = new Bot('YOUR-TOKEN-GOES-HERE');
var bot = new Bot(token);
bot.login();

0 comments on commit 6e403de

Please sign in to comment.