Skip to content

Commit 3b392d7

Browse files
authored
Merge branch 'heroku-dota' into dota
2 parents 51d29dd + be5205c commit 3b392d7

File tree

5 files changed

+81
-79
lines changed

5 files changed

+81
-79
lines changed

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bot: node ./lib/index.js

README.md

+69-67
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,101 @@
1-
# [ScheduleBot | Dota Edition](https://mellamopablo.github.io/schedulebot/)
2-
> A Discord bot that makes scheduling easy
3-
4-
*Note: you're currently viewing the Dota version. This version supports Dota 2 inhouses and its
5-
configuration is a bit trickier because you need a Steam Bot. If you're looking for the standard
6-
version, [go here](https://github.com/MeLlamoPablo/schedulebot/tree/master#schedulebot).*
7-
8-
ScheduleBot is a bot that manages events, such as a practice game with your team, or a league
9-
inhouse, or a tournament match.
10-
11-
## Features
12-
13-
* **Dota inhouses**: the Dota version makes it easy to create inhouses, as you can link an event
14-
to an inhouse. A Dota bot will automatically create a lobby and invite every player who have
15-
confirmed their attendance.
16-
* **Time zone handling**: ScheduleBot manages timezons for you. If there are European and
17-
American people on your team, if an European creates an event, Americans will be able to convert
18-
it to their timezone with the `convert` command.
19-
* **Confirm and reject handling**: ScheduleBot allows users to confirm or deny their attendance
20-
to an event, so you can see who and how many people are you gonna play with. ScheduleBot can also
21-
limit how many people can attend an event.
22-
* **Admin commands**: ScheduleBot allows elevated privilege commands with `schedulebot-admin`.
23-
Admins can perform actions such as removing events, or blacklisting an user to prevent them to
24-
use the bot.
25-
* **Linking an event to a role**: ScheduleBot allows events to be linked to a role, so that
26-
members of that role can be notified when they are required to confirm or deny attendance to an
27-
event.
28-
29-
## Local installation
30-
31-
To run ScheduleBot Dota Edition locally, you will need:
1+
# Heroku deployment guide
2+
3+
*Note: you're currently viewing the Dota version. This version supports Dota 2 inhouses and its
4+
configuration is a bit trickier because you need a Steam Bot. If you're looking for the standard
5+
version, go
6+
[here](https://github.com/MeLlamoPablo/schedulebot/tree/heroku#heroku-deployment-guide).*
7+
8+
*If you're looking for the local installation instructions, go
9+
[here](https://github.com/MeLlamoPablo/schedulebot/tree/dota#schedulebot--dota-edition).*
10+
11+
If you wanted to host ScheduleBot locally, you'd need to have your computer on 24/7 to have your
12+
bot always online. To avoid that, we could use a PaaS provider, such as
13+
[Heroku](https://www.heroku.com/). Heroku's free plan is good enough for hosting our bot.
14+
15+
## Deployment instructions
16+
17+
To deploy ScheduleBot to Heroku, you will need:
3218

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

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

4127
```sh
42-
$ git clone https://github.com/MeLlamoPablo/schedulebot.git
28+
$ git clone https://github.com/<your_github_username>/schedulebot.git
4329
$ cd schedulebot
30+
$ git checkout heroku-dota
4431
$ npm install
4532
```
4633

47-
And edit the bot's settings in `config.js`. You can edit or leave whatever you want, but you
48-
should at least edit:
34+
The `heroku-dota` branch is ready to be compatible with Heroku. The differences from `dota` are:
35+
36+
* The database settings are no longer stored in `config.js`, as they are provided by Heroku through
37+
an environment variable.
38+
* The `package.json` file is modified to tell Heroku to use Node 6.
39+
* A `Procfile` with your bot's process is included.
40+
41+
Now edit the bot's settings in `config.js`. You can edit or leave whatever you want, but you should
42+
at least edit:
4943

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

57-
Now, make sure that your postgres server is running, and run the database setup script:
49+
Next step is configuring your database. In your app's dashboard, go to `Resources`, and under
50+
`Add-ons`, click `Find more add-ons`. Then search `Heroku Posgres` and add it to your app. The
51+
free version is good enough for personal use.
52+
53+
After adding it, you'll find it under the `Add-ons` section. Click on it to your Heroku Postgres
54+
dashboard, and then click on your newly created Datastore. Scroll down to `Database Credentials`,
55+
and click `View Credentials`. Now run the setup script entering those credentials:
5856

5957
```sh
6058
$ npm run setup
6159
```
6260

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

6964
```sh
7065
$ npm run setup-steam
7166
```
7267

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

7570
```sh
76-
$ npm run bot
71+
$ git add .
72+
git commit -m "Ready to deploy"
73+
$ git push --all
7774
```
7875

79-
## Usage guide
76+
Before deploying your bot, let's add your bot user to your Discord server. In order to do so, go
77+
to the [Discord dev center](https://discordapp.com/developers/applications/me/) and click on your
78+
application, then grab your Client ID. Then go to the following link in your browser:
79+
80+
```
81+
https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=0x00002000
82+
```
8083

81-
After installing your bot, you might want to check out the
84+
Replace `YOUR_CLIENT_ID` by your bot's client ID. Don't forget to grant the "Manage Messages"
85+
permission.
86+
87+
Now, in your Heroku dashboard, go to `Deploy`, select `GitHub`, connect your account, and add
88+
your fork. Be sure to select the `heroku-dota` branch.
89+
90+
The first build should be triggered. When it's done, navigate to `Resources`, and, if everything
91+
went right, you should see two Dynos: `web`, and `bot`. Shutdown `web`, as we don't need it, and
92+
turn on `bot`. After that, your bot will be loaded. Go to the top right corner, under `More`,
93+
then `View Logs` to see the console log. If you see the message
94+
`[INFO] ScheduleBot finished loading.`, the bot is live. Congratulations!
95+
96+
# Usage guide
97+
98+
After deploying your bot, you might want to check out the
8299
[usage guide](https://github.com/MeLlamoPablo/schedulebot/blob/dota/usage/usage-guide.md).
83100

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

125-
You're now ready to run your bot again.
126-
127-
## Deploying to Heroku
128-
129-
If you wanted to host ScheduleBot locally, you'd need to have your computer on 24/7 to have your bot
130-
always online. To avoid that, we could use a PaaS provider, such as Heroku. Heroku's free plan is
131-
good enough for hosting our bot. To learn how to deploy the bot to heroku,
132-
[go here](https://github.com/MeLlamoPablo/schedulebot/tree/heroku-dota#heroku-deployment-guide).
133-
134-
## Changelog
135-
136-
The change log can be found at the [releases section](https://github.com/MeLlamoPablo/schedulebot/releases).
137-
138-
## License
139-
140-
Apache-2.0 © [Pablo Rodríguez](https://github.com/MeLlamoPablo)
142+
You're now ready to run your bot again.

config.js

-7
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ module.exports = {
9090
event_name: "Inhouse"
9191
},
9292

93-
db: {
94-
"user": "",
95-
"password": "",
96-
"host": "",
97-
"database": ""
98-
},
99-
10093
steam: {
10194
// The name that the Steam bots will take. It will be appended with "#id" as in "#1".
10295
name: "ScheduleBot",

lib/modules/dbhandler/core.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"use strict";
22

3-
const cfg = require('../../../config.js');
4-
const moment = require('moment');
5-
const db = require('knex')({
3+
const cfg = require('../../../config.js');
4+
const moment = require('moment');
5+
const pg = require('pg');
6+
7+
pg.defaults.ssl = true;
8+
9+
const db = require('knex')({
610
client: 'pg',
7-
connection: "postgres://" + cfg.db.user + ":" + cfg.db.password
8-
+ "@" + cfg.db.host + "/" + cfg.db.database + ""
11+
connection: process.env.DATABASE_URL
912
});
1013

1114
const events = {

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@
4949
},
5050
"bugs": {
5151
"url": "https://github.com/mellamopablo/schedulebot/issues"
52+
},
53+
"engines":{
54+
"node": "6.3.1"
5255
}
5356
}

0 commit comments

Comments
 (0)