diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..c092a2636
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright 2019 GroupMe
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index ca1961fed..0d37b1a4c 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,9 @@
-# Sample GroupMe NodeJS Callback Bot
+# Sample GroupMe NodeJS Bot
+[**Python**](https://github.com/groupme/bot-tutorial-python) | **JavaScript**
## Introduction
-This project shows the capability of a bot to react to messages sent within a group.
+A simple GroupMe bot that reacts to messages sent in a group.
## Contents
@@ -18,7 +19,7 @@ This project shows the capability of a bot to react to messages sent within a gr
* GroupMe account
* Heroku account
- * [Heroku Toolbelt](https://toolbelt.heroku.com/)
+ * [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli)
# Get your bot up and running
@@ -55,10 +56,10 @@ Fill out the form to create your new bot:
* Select the group where you want the bot to live
* Give your bot a name
- * Paste in the url to your newly deply heroku app
+ * Paste in the URL of your newly deployed Heroku app
* `http://your-app-name-here.herokuapp.com/`
- * (Optional) Give your bot an avatar by providing a url to an image
- * Click submit
+ * (Optional) Give your bot an avatar by providing the URL of an image
+ * Click submit!
## Find your Bot ID:
@@ -113,37 +114,51 @@ Go to GroupMe and type "/cool guy" in the group where your bot lives to see it i
Within terminal, change directory to the location where you would like the files to live, then run this command:
- $ heroku git:clone -a YOUR_APP_NAME_HERE
+```sh
+heroku git:clone -a YOUR_APP_NAME_HERE
+```
And then change directory into the new folder
- $ cd YOUR_APP_NAME_HERE
+```sh
+cd YOUR_APP_NAME_HERE
+```
## Configure your local BOT_ID environment variable
Open the file `.env` from your local files in your text editor of choice.
Find where it says "YOUR_BOT_ID_HERE" and replace it with the ID of your new bot.
-If you don't know what your Bot ID is, please refer back to [this](#get-bot-id) section,
-where it is explained how to retrieve it.
+If you don't know what your Bot ID is, please refer back to [this](#get-bot-id) section, where it is explained how to retrieve it.
If your Bot ID is 12345678910, then:
- BOT_ID="YOUR_BOT_ID_HERE"
+```sh
+BOT_ID="YOUR_BOT_ID_HERE"
+```
becomes:
- BOT_ID="12345678910"
+```sh
+BOT_ID="12345678910"
+```
## Start the server
To test your bot locally, open terminal and run the following command to start a local server.
- $ foreman start
+```sh
+npm start
+```
+
+or
+
+```sh
+node index.js
+```
Then navigate to `http://127.0.0.1:5000/` in a browser.
![Local bot](http://i.groupme.com/502x133.png.f06c630467954f5dab4c742dc67b71bf)
## All done! Go play around and make the bot your own.
-
diff --git a/app.json b/app.json
index 693c54cf0..e397ca55e 100644
--- a/app.json
+++ b/app.json
@@ -1,7 +1,7 @@
{
"name": "Cool guy bot",
- "description": "Basic Groupme Bot written in Node",
- "repository": "https://github.com/petemcgrath/cool-guy-bot",
+ "description": "Basic GroupMe Bot written in Node.js",
+ "repository": "https://github.com/groupme/bot-tutorial-nodejs",
"logo": "http://www.tailgate365.com/wp-content/uploads/2011/06/tom-hanks-906.jpg",
"keywords": []
}
diff --git a/bot.js b/bot.js
index d04b04016..90e70911e 100644
--- a/bot.js
+++ b/bot.js
@@ -7,12 +7,12 @@ function respond() {
var request = JSON.parse(this.req.chunks[0]),
botRegex = /^\/cool guy$/;
- if(request.text && botRegex.test(request.text)) {
+ if (request.text && botRegex.test(request.text)) {
this.res.writeHead(200);
postMessage();
this.res.end();
} else {
- console.log("don't care");
+ console.log('Received irrelevant message.');
this.res.writeHead(200);
this.res.end();
}
@@ -30,18 +30,18 @@ function postMessage() {
};
body = {
- "bot_id" : botID,
- "text" : botResponse
+ 'bot_id' : botID,
+ 'text' : botResponse
};
console.log('sending ' + botResponse + ' to ' + botID);
botReq = HTTPS.request(options, function(res) {
- if(res.statusCode == 202) {
- //neat
- } else {
- console.log('rejecting bad status code ' + res.statusCode);
- }
+ if (res.statusCode == 202) {
+ // Request was successful.
+ } else {
+ console.log('received bad status code ' + res.statusCode);
+ }
});
botReq.on('error', function(err) {
@@ -54,4 +54,4 @@ function postMessage() {
}
-exports.respond = respond;
\ No newline at end of file
+exports.respond = respond;
diff --git a/index.js b/index.js
index 672900471..07d700f73 100644
--- a/index.js
+++ b/index.js
@@ -30,4 +30,4 @@ server.listen(port);
function ping() {
this.res.writeHead(200);
this.res.end("Hey, I'm Cool Guy.");
-}
\ No newline at end of file
+}
diff --git a/package.json b/package.json
index 3f18ebf6c..1f17b7e24 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
- "name": "node-js-getting-started",
+ "name": "bot-tutorial",
"version": "0.1.2",
- "description": "A sample Node.js app using Express 4",
+ "description": "A simple GroupMe bot written in Node.js",
"main": "index.js",
"scripts": {
"start": "node index.js"
@@ -15,12 +15,14 @@
},
"repository": {
"type": "git",
- "url": "https://github.com/heroku/node-js-getting-started"
+ "url": "https://github.com/groupme/bot-tutorial-nodejs"
},
"keywords": [
"node",
"heroku",
- "express"
+ "express",
+ "groupme",
+ "bot"
],
"license": "MIT"
}