Skip to content

Commit

Permalink
Merge pull request #67 from JamesLongman/develop
Browse files Browse the repository at this point in the history
Project markdown files
  • Loading branch information
JamesLongman committed Nov 12, 2018
2 parents 87c361c + d24e8ea commit 4dd2b9d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ config/local.json
# Ignore all md files
*.md

# Ignore all hidden files(git, travis, docker, etc)
# Ignore all hidden files (git, travis, docker, etc)
.*

# Ignore all docker files
Dockerfile
docker-compose*.yml
docker-compose*.yml
65 changes: 9 additions & 56 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To give a basic setup procedure:
- Create a personal bot here: (you will need multiple for sub-bots) https://discordapp.com/developers/applications/
- Update your config files with the parameters you have created with your bots and servers
- Install and run docker
- Run the project using `docker-compose up --build`
- Run the project using `npm run up`

# Installing Docker

Expand All @@ -19,61 +19,11 @@ We **HIGHLY** recommend the use of Docker in order to run DIGBot. This will ensu

# Your local config files

You need a file at config/envConfig.js, this should be git Ignored. You will need to change all parameters in the config/envConfig.js and config/development/\*.js files to ensure they match your personal development discord server and bot API keys and such. It is **CRITICAL** that you keep these files out of the commit history by use of a command such as `git update-index --assume-unchanged config/envConfig.js` if necessary to keep private keys secure
You need a file at config/local.json, this should be git Ignored. You will need to change all parameters in the config/local.json file to ensure they match your personal development discord server and bot API keys and such, to accomplish this you may use config.local.json.example as a guide. It is **CRITICAL** that you keep these files out of the commit history by use of a command such as `git update-index --assume-unchanged config/local.json` if necessary to keep private keys secure.

# Code style Guide

### Control structures

```
// Functions
function {
...
}
// IF statements
if (! <expression>) {
...
} else if (<expression>) {
...
} else {
...
}
// For loops
for (let count = 0; count > <something>; count++) {
...
}
// While loops
while (something !== something) {
...
}
```
### Module variables declarations

```
"use strict";
const someVar = something;
let someGlobalVar = something;
modules.exports = {
someFunction: function () {
...
},
someOtherFunction: someNonModularFunction // Pointing to a normal function
}
function someNonModularFunction {
...
}
```
### Module organization

- Comply with Atom JSLinter and JSCS plugins. Added the .jscsrc file to master so it can be consistent across all developers. (This will soon change to a CI process)
- Comply with the .jscsrc file, you may use a linter in your IDE to assist you in this however how this is accomplished will depend on your IDE. Style is automatically reviewed in PRs through our CI process.
- Leave a summary comment at the top of each module explaining its purpose
- Sort functions alphabetically unless using getter and setter functions, example:
```
Expand All @@ -83,12 +33,15 @@ setSomething()
getSomethingElse()
setSomethingElse()
```
- If the purpose of a function is not immediately apparent leave a short comment
- Ensure promise resolutions/rejections are handled
- Embed promise structures, see code for examples
- If the purpose of a function is not immediately apparent leave a short comment. Please keep in mind our comments are intended to be read by recreational developers, not professsionals.
- Ensure promise resolutions/rejections are always handled
- Please keep in mind due to API ping a lot of our code must be designed with asynchronicity in mind
- Where possible guard against common errors and handle them through our logger (src/lib.logger.js)

### Module testing

If it can be tested it should be tested, test coverage should be as high as possible. Tests are conducted automatically on all PRs by Travis.

For testing this codebase uses Chai and Sinon with Mocha as runner. Mocha
allows organisation of tests by means of describing testable code blocks and
tests that needs passing. Most tests use the `should` variant of Chai, with
Expand Down
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 DIG Development Team

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.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,17 @@ Some channels the community would prefer to always have a free version of. This

The bot uses docker 1.13.0+. Installation instructions can be found here: https://docs.docker.com/install/

### From Docker Hub
### Deployment via Docker Hub

It is possible to pull the latest image from Docker Hub using `docker pull dignityofwar/digbot`. Check the readme file in config to configure the bot correctly.
Docker Hub automatically builds and stores docker images of staging and master (our production branch). We deploy the bot using the latest docker images from Docker Hub using `docker pull dignityofwar/digbot`.

### From the repository

To run the bot locally use `npm run docker:start`, to check the logs use `npm run docker:logs`, and to stop the container and remove it use `npm run docker:stop`. To quickly run the container and view it's logs use `npm run up`, and for taking it down use `npm run down`. The local.json config file will be automatically linked to the container. It is possible to run the bot without docker using `npm start`, but this is not recommended.
To run the bot locally use `npm run up`, and to stop the container and remove it use `npm run down`. The local.json config file will be automatically linked to the container.

To run the tests you use `npm test` (this will also link the local.json config file). It is possible to run it without docker using `npm run mocha`, but this is not recommended.
To run the tests you use `npm test` (this will also link the local.json config file).

It is of course possible to run it without docker, but this is not recommended.

## Development

Expand All @@ -123,11 +125,11 @@ See the [contribution guidelines](CONTRIBUTING.md) file for information on how t

### Code Usage

The project is in the process of being open sourced however as of this moment no usage licence is provided.
The project is open-sourced under the [MIT license](LICENSE.md).

### Acknowledgements

This repository was created from an [existing private codebase](https://github.com/JamesLongman/DIGBot/releases/tag/0.0.1) for DIGBot which can be found. The previous project was headed by Maelstromeous who was ultimately responsible for code review, design decisions and deployment.
This repository was created from an [existing private codebase](https://github.com/JamesLongman/DIGBot/releases/tag/0.0.1). The previous project was headed by Maelstromeous who was ultimately responsible for code review, design decisions and deployment.

File contributions were as follows
Maelstromeous: 510 commits, 7,623 additions, 6,378 deletions
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// !stats module

const config = require('config');
const pjson = require('../../../package');
const logger = require('../logger.js');
const performance = require('../tools/performance.js');
const pjson = require('../../../package');
const server = require('../server/server.js');
const TAG = '!stats';

Expand Down
3 changes: 2 additions & 1 deletion src/lib/discord/bot-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const directMessage = require('./direct-message.js');
const crashHandler = require('../crash-handling.js');
const logger = require('../logger.js');
const nameCheck = require('../welcomepack/namecheck.js');
const pjson = require('../../../package.json');
const server = require('../server/server.js');
const subBots = require('../sub-bots/sub-bots.js');
const welcome = require('../welcomepack/welcomepack.js');
Expand Down Expand Up @@ -185,7 +186,7 @@ module.exports = {

if (server.getBooted() === false) {
if (server.getChannel('developers') !== null) {
server.getChannel('developers').sendMessage(`DIGBot, reporting for duty! Environment: ${config.util.getEnv('NODE_ENV')}`)
server.getChannel('developers').sendMessage(`DIGBot, reporting for duty! Environment: ${config.util.getEnv('NODE_ENV')}, Version: ${pjson.version}`)
.then(
logger.debug(TAG, 'Succesfully sent message')
)
Expand Down

0 comments on commit 4dd2b9d

Please sign in to comment.