Skip to content

Commit

Permalink
Revert "Merge branch 'heroku-dota' into dota"
Browse files Browse the repository at this point in the history
This reverts commit 3b392d7.

Reason: I fucked up.
  • Loading branch information
MeLlamoPablo committed Jan 24, 2017
1 parent 3b392d7 commit c7f113f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 81 deletions.
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

136 changes: 67 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,84 @@
# Heroku deployment guide

*Note: you're currently viewing the Dota version. This version supports Dota 2 inhouses and its
configuration is a bit trickier because you need a Steam Bot. If you're looking for the standard
version, go
[here](https://github.com/MeLlamoPablo/schedulebot/tree/heroku#heroku-deployment-guide).*

*If you're looking for the local installation instructions, go
[here](https://github.com/MeLlamoPablo/schedulebot/tree/dota#schedulebot--dota-edition).*

If you wanted to host ScheduleBot locally, you'd need to have your computer on 24/7 to have your
bot always online. To avoid that, we could use a PaaS provider, such as
[Heroku](https://www.heroku.com/). Heroku's free plan is good enough for hosting our bot.

## Deployment instructions

To deploy ScheduleBot to Heroku, you will need:
# [ScheduleBot | Dota Edition](https://mellamopablo.github.io/schedulebot/)
> A Discord bot that makes scheduling easy
*Note: you're currently viewing the Dota version. This version supports Dota 2 inhouses and its
configuration is a bit trickier because you need a Steam Bot. If you're looking for the standard
version, [go here](https://github.com/MeLlamoPablo/schedulebot/tree/master#schedulebot).*

ScheduleBot is a bot that manages events, such as a practice game with your team, or a league
inhouse, or a tournament match.

## Features

* **Dota inhouses**: the Dota version makes it easy to create inhouses, as you can link an event
to an inhouse. A Dota bot will automatically create a lobby and invite every player who have
confirmed their attendance.
* **Time zone handling**: ScheduleBot manages timezons for you. If there are European and
American people on your team, if an European creates an event, Americans will be able to convert
it to their timezone with the `convert` command.
* **Confirm and reject handling**: ScheduleBot allows users to confirm or deny their attendance
to an event, so you can see who and how many people are you gonna play with. ScheduleBot can also
limit how many people can attend an event.
* **Admin commands**: ScheduleBot allows elevated privilege commands with `schedulebot-admin`.
Admins can perform actions such as removing events, or blacklisting an user to prevent them to
use the bot.
* **Linking an event to a role**: ScheduleBot allows events to be linked to a role, so that
members of that role can be notified when they are required to confirm or deny attendance to an
event.

## Local installation

To run ScheduleBot Dota Edition locally, you will need:

* [NodeJS](https://nodejs.org/en/download/) 6 or above.
* [git](https://git-scm.com/downloads).
* [PostgreSQL](https://www.postgresql.org/download/).
* You'll need to create an empty database for ScheduleBot.
* [git](https://git-scm.com/downloads), so you can easily clone this repo (optional).
* A second [Steam](http://steamcommunity.com/) account for your bot.

First, [sign up to Heroku](https://signup.heroku.com/), and create an app. You may deploy your
bot using the Heroku CLI, or GitHub. I recommend GitHub, as it's easier. If you choose Heroku
CLI, follow the instructions there. If you choose GitHub, first fork this repository. Then, clone
your fork and checkout the `heroku-dota` branch, and install the dependencies:
Start by cloning this repo, and then install the dependencies:

```sh
$ git clone https://github.com/<your_github_username>/schedulebot.git
$ git clone https://github.com/MeLlamoPablo/schedulebot.git
$ cd schedulebot
$ git checkout heroku-dota
$ npm install
```

The `heroku-dota` branch is ready to be compatible with Heroku. The differences from `dota` are:

* The database settings are no longer stored in `config.js`, as they are provided by Heroku through
an environment variable.
* The `package.json` file is modified to tell Heroku to use Node 6.
* A `Procfile` with your bot's process is included.

Now edit the bot's settings in `config.js`. You can edit or leave whatever you want, but you should
at least edit:
And edit the bot's settings in `config.js`. You can edit or leave whatever you want, but you
should at least edit:

* `master_channel` with the Discord channel where your bot will operate.
* If you don't know how to get it, go to Discord's settings, then `Appearance`, then check
`Developer Mode`. After that, right click on your channel, and click `Copy ID`.
* `default_timezone` with the time zone which will be used by the bot.
* `db` with yout postgres database settings.
* `steam.profile_url` with your Steam bot's profile URL.

Next step is configuring your database. In your app's dashboard, go to `Resources`, and under
`Add-ons`, click `Find more add-ons`. Then search `Heroku Posgres` and add it to your app. The
free version is good enough for personal use.

After adding it, you'll find it under the `Add-ons` section. Click on it to your Heroku Postgres
dashboard, and then click on your newly created Datastore. Scroll down to `Database Credentials`,
and click `View Credentials`. Now run the setup script entering those credentials:
Now, make sure that your postgres server is running, and run the database setup script:

```sh
$ npm run setup
```

After that, you need to configure your Steam credentials. You'll need to re-enter your Heroku
Postgres database credentials on the Steam setup script.
The script will take your database settings from `config.js`, so you can just go ahead and press
enter. When asked if you want to connect over SSL, unless you have configured your postgres
server to use it, you should say no. Then follow the script's instructions to finish the setup.

After that, you need to configure your Steam credentials:

```sh
$ npm run setup-steam
```

Follow the script's instructions. After you're done, you're ready to push your repo to GitHub:
Follow the script's instructions and you're good to go. You can run then your bot with:

```sh
$ git add .
git commit -m "Ready to deploy"
$ git push --all
$ npm run bot
```

Before deploying your bot, let's add your bot user to your Discord server. In order to do so, go
to the [Discord dev center](https://discordapp.com/developers/applications/me/) and click on your
application, then grab your Client ID. Then go to the following link in your browser:

```
https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=0x00002000
```
## Usage guide

Replace `YOUR_CLIENT_ID` by your bot's client ID. Don't forget to grant the "Manage Messages"
permission.

Now, in your Heroku dashboard, go to `Deploy`, select `GitHub`, connect your account, and add
your fork. Be sure to select the `heroku-dota` branch.

The first build should be triggered. When it's done, navigate to `Resources`, and, if everything
went right, you should see two Dynos: `web`, and `bot`. Shutdown `web`, as we don't need it, and
turn on `bot`. After that, your bot will be loaded. Go to the top right corner, under `More`,
then `View Logs` to see the console log. If you see the message
`[INFO] ScheduleBot finished loading.`, the bot is live. Congratulations!

# Usage guide

After deploying your bot, you might want to check out the
After installing your bot, you might want to check out the
[usage guide](https://github.com/MeLlamoPablo/schedulebot/blob/dota/usage/usage-guide.md).

## Updating
Expand Down Expand Up @@ -139,4 +122,19 @@ When prompted to select the current version, select the version you took note of
to select the target version, you generally want to select the latest. After that, enter your
database credentials, and your database will also be updated to the selected version.

You're now ready to run your bot again.
You're now ready to run your bot again.

## Deploying to Heroku

If you wanted to host ScheduleBot locally, you'd need to have your computer on 24/7 to have your bot
always online. To avoid that, we could use a PaaS provider, such as Heroku. Heroku's free plan is
good enough for hosting our bot. To learn how to deploy the bot to heroku,
[go here](https://github.com/MeLlamoPablo/schedulebot/tree/heroku-dota#heroku-deployment-guide).

## Changelog

The change log can be found at the [releases section](https://github.com/MeLlamoPablo/schedulebot/releases).

## License

Apache-2.0 © [Pablo Rodríguez](https://github.com/MeLlamoPablo)
7 changes: 7 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ module.exports = {
event_name: "Inhouse"
},

db: {
"user": "",
"password": "",
"host": "",
"database": ""
},

steam: {
// The name that the Steam bots will take. It will be appended with "#id" as in "#1".
name: "ScheduleBot",
Expand Down
13 changes: 5 additions & 8 deletions lib/modules/dbhandler/core.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
"use strict";

const cfg = require('../../../config.js');
const moment = require('moment');
const pg = require('pg');

pg.defaults.ssl = true;

const db = require('knex')({
const cfg = require('../../../config.js');
const moment = require('moment');
const db = require('knex')({
client: 'pg',
connection: process.env.DATABASE_URL
connection: "postgres://" + cfg.db.user + ":" + cfg.db.password
+ "@" + cfg.db.host + "/" + cfg.db.database + ""
});

const events = {
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,5 @@
},
"bugs": {
"url": "https://github.com/mellamopablo/schedulebot/issues"
},
"engines":{
"node": "6.3.1"
}
}

0 comments on commit c7f113f

Please sign in to comment.