Skip to content

Commit bae097c

Browse files
committed
v1.2.0
Closes #12 Squashed commit of the following: commit c4fcd1b Author: Pablo Rodríguez <[email protected]> Date: Tue Jan 24 13:03:58 2017 +0100 Added some config options. Final v1.2 commit- commit 64e97d7 Author: Pablo Rodríguez <[email protected]> Date: Mon Jan 23 14:11:24 2017 +0100 Added enfore MMR ability commit 9b35426 Author: Pablo Rodríguez <[email protected]> Date: Fri Jan 20 12:23:23 2017 +0100 Removed uneccessary comment commit b69cc92 Author: Pablo Rodríguez <[email protected]> Date: Fri Jan 20 12:21:00 2017 +0100 The bot is able to retrieve the Match ID commit 47f41fe Author: Pablo Rodríguez <[email protected]> Date: Tue Jan 17 21:52:10 2017 +0100 Bug fixes commit 10ebaff Author: Pablo Rodríguez <[email protected]> Date: Mon Jan 16 13:12:16 2017 +0100 Updated usage guide commit dc4989e Author: Pablo Rodríguez <[email protected]> Date: Mon Jan 16 13:02:08 2017 +0100 Added CM Pick option (Needs testing) commit 35c3bfd Author: Pablo Rodríguez <[email protected]> Date: Sun Jan 15 17:32:46 2017 +0100 Finished MMR support. commit 3749e1e Author: Pablo Rodríguez <[email protected]> Date: Sun Jan 15 02:08:46 2017 +0100 Fetching MMR from OpenDota commit 021bae7 Author: Pablo Rodríguez <[email protected]> Date: Sat Jan 14 17:19:16 2017 +0100 Merge branch 'dota-feature-multiple-steam-bots' Squashed commit of the following: commit ff26b5d Author: Pablo Rodríguez <[email protected]> Date: Sat Jan 14 17:15:09 2017 +0100 Works apparently. commit bed8095 Author: Pablo Rodríguez <[email protected]> Date: Fri Jan 13 11:34:17 2017 +0100 small progress commit 07a80e5 Author: Pablo Rodríguez <[email protected]> Date: Thu Jan 12 20:47:31 2017 +0100 Fixed some things + status command (untested) commit 5594b93 Author: Pablo Rodríguez <[email protected]> Date: Thu Jan 12 14:06:28 2017 +0100 Seems to work now commit e864b89 Author: Pablo Rodríguez <[email protected]> Date: Thu Jan 12 13:26:51 2017 +0100 Getting an error on lobby creation commit 100c4df Author: Pablo Rodríguez <[email protected]> Date: Wed Jan 11 20:41:56 2017 +0100 Still a wip... commit 64bb4e1 Author: Pablo Rodríguez <[email protected]> Date: Wed Jan 11 13:30:49 2017 +0100 Forgot to upload the next version sql changes commit 977b5cb Author: Pablo Rodríguez <[email protected]> Date: Wed Jan 11 13:29:45 2017 +0100 Still a wip I'm making soooooo much changes without testing, but I can't right now. Debugging is gonna be fun. commit 403bf75 Merge: 227c59a 4b005fd Author: Pablo Rodríguez <[email protected]> Date: Wed Jan 11 12:01:08 2017 +0100 Merge branch 'dota-dev' into dota-feature-multiple-steam-bots commit 227c59a Author: Pablo Rodríguez <[email protected]> Date: Sat Jan 7 14:22:57 2017 +0100 Still a work in progress Rewriting the dotahandler module. commit 5d1aa84 Author: Pablo Rodríguez <[email protected]> Date: Fri Jan 6 21:38:12 2017 +0100 Doesn't work so far commit a95b25e Author: Pablo Rodríguez <[email protected]> Date: Fri Jan 6 13:28:27 2017 +0100 Changed scripts to work with multiple bots commit 4b005fd Merge: cacfeb8 86629b0 Author: Pablo Rodríguez <[email protected]> Date: Wed Jan 11 12:00:38 2017 +0100 Merge branch 'dota' into dota-dev commit cacfeb8 Merge: 69caf3c d30d919 Author: Pablo Rodríguez <[email protected]> Date: Fri Jan 6 11:43:09 2017 +0100 Merged branch dota into dota-dev
1 parent 86629b0 commit bae097c

38 files changed

+2083
-695
lines changed

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,20 @@ used `git` to clone the repository, this is easy:
100100
$ git pull --all
101101
```
102102

103-
If you forked this repo to deploy to Heroku, this will not work, because it's pulling from your repo, and not from this one. To solve that, first [configure this repo (MeLlamoPablo/schedulebot) as a remote for your fork (YOUR_GITHUB_USERNAME/schedulebot)](https://help.github.com/articles/configuring-a-remote-for-a-fork/). Then, [fetch this repo](https://help.github.com/articles/syncing-a-fork/) *(change `master` to `dota` or `heroku-dota`, depending on what branch you're working with)*.
103+
If you forked this repo to deploy to Heroku, this will not work, because it's pulling from your
104+
repo, and not from this one. To solve that, first [configure this repo (MeLlamoPablo/schedulebot)
105+
as a remote for your fork (YOUR_GITHUB_USERNAME/schedulebot)](https://help.github.com/articles/configuring-a-remote-for-a-fork/).
106+
Then, [fetch this repo](https://help.github.com/articles/syncing-a-fork/)
107+
*(change `master` to `dota` or `heroku-dota`, depending on what branch you're working with)*.
104108

105-
However, after this your bot is not ready yet. A database update is also required:
109+
After that, perform another npm install to make sure that you get any new dependencies or update
110+
existing ones:
111+
112+
```
113+
$ npm install
114+
```
115+
116+
However, after all of this your bot is not ready yet. A database update is also required:
106117

107118
```sh
108119
$ npm run update

config.js

+42-6
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ module.exports = {
6161
// More info: https://discordapp.com/developers/docs/topics/permissions
6262
delete_after_reply: {
6363
enabled: true,
64-
time: 60000, // In milliseconds
64+
time: 60000 // In milliseconds
6565
},
6666

6767
// If true, it will delete any message that is not a command from the master channel.
6868
// Leave this on to keep your master channel tidy.
6969
// This also requires the "manage messages" permission
7070
disallow_talking: true,
7171

72+
// If false, all (non-blacklisted) users will be able to add inhouses to created events.
73+
// If true, only admins will be able to do so.
74+
add_inhouse_is_admin_command: false,
75+
7276
// quick-inhouse command
7377
// This command creates an instant lobby and adds an inhouse with the default values.
7478
// It is the equivalent of running "@ScheduleBot create (event_name) now" and
@@ -94,26 +98,58 @@ module.exports = {
9498
},
9599

96100
steam: {
97-
// The name that the Steam bot will take
101+
// The name that the Steam bots will take. It will be appended with "#id" as in "#1".
98102
name: "ScheduleBot",
99103

100-
// The bot's profile URL. It's needed to redirect users to it.
104+
// The first bot's profile URL. It's needed to redirect users to it.
101105
profile_url: "http://steamcommunity.com/profiles/YOUR_BOT_ID/"
102106
},
103107

104108
dota: {
105109
// The default inhouse server, which will be used if the user doesn't pass the
106110
// --server flag to the add-inhouse command.
107-
// Go to that command's file (Or type -schedulebot add-ihouse --help)
111+
// Go to that command's file (Or type -schedulebot add-inhouse --help)
108112
// to see possible values.
109-
defaultServer: "Luxembourg",
113+
default_server: "Luxembourg",
114+
115+
// If false, lobbies will be started automatically when ten people join it
116+
// (spectators, casters and unassigned players not counted).
117+
// If true, the games will only be able to be started with the admin command
118+
// schedulebot-admin force-lobby-start (event)
119+
disable_autostart: false,
110120

111121
// If enabled is true, the bot will ticket any lobbies using the provided league id.
112122
// Make sure that the steam bot is an admin of that league.
113123
ticketing: {
114124
enabled: false,
115125
league_id: 12345
116-
}
126+
},
127+
128+
// If enabled is true, the bot will fetch MMR from OpenDota for every user that links
129+
// their Steam account, and display it in event summaries.
130+
//
131+
// The user must have the "Expose Public Match Data" option enabled, must be displaying
132+
// their MMR on their Dota profile, and must have signed in OpenDota at least once, using
133+
// Steam. If OpenDota doesn't know the user MMR, ScheduleBot won't either, and will display
134+
// a "MMR Unknown message"
135+
mmr: {
136+
enabled: true,
137+
138+
// If enforce is true, the bot will only allow people who have their MMR publicly
139+
// exposed in OpenDota to confirm any events. This is useful for competitive leagues
140+
// who need to control MMR; it's recommended to leave it false otherwise.
141+
enforce: false,
142+
143+
// ScheduleBot will update all users' MMR on each interval.
144+
update_interval: 8 // In hours
145+
},
146+
147+
// In a competitive league, you might want to change this with "match" or "game",
148+
// since it's not technically an inhouse.
149+
//
150+
// CAREFUL! This will change the name of the command "add-inhouse"
151+
// to "add-whatever_you_write"
152+
game_generic_name: "inhouse"
117153
}
118154
};
119155

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

3-
const Clapp = require('../../modules/clapp-discord/index');
3+
const Clapp = require("../../modules/clapp-discord")
4+
, ECloseLobbyError = require("../../structures/enums/ECloseLobbyError")
5+
, db = require("../../modules/dbhandler")
6+
;
47

58
module.exports = new Clapp.Command({
69
name: "force-lobby-start",
7-
desc: "Forces the current lobby to start, even if there aren't enough players.",
10+
desc: "Forces the lobby for the specified event to start, even if there aren't enough players.",
811
fn: (argv, context) => {
912
return new Promise((fulfill, reject) => {
10-
context.dotaHandler.forceStart().catch(reject);
11-
fulfill("Forced current lobby start");
13+
db.events.get(argv.args.event).then(event => {
14+
if (event !== null) {
15+
db.events.getLobbyBotId(event)
16+
.then(botID => {
17+
fulfill(`Forced lobby start for the event ${event.id}.`);
18+
context.dotaHandler.forceLobbyStart(botID).catch(reject);
19+
})
20+
.catch(reject);
21+
} else {
22+
fulfill("Error: the specified event `" + argv.args.event + "` doesn't exist.");
23+
}
24+
}).catch(reject);
1225
});
13-
}
26+
},
27+
args: [
28+
require("./shared/event")
29+
]
1430
});

lib/commands/admin/get-lobby.js

+27-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
"use strict";
22

3-
const Clapp = require('../../modules/clapp-discord/index');
3+
const Clapp = require("../../modules/clapp-discord")
4+
, db = require("../../modules/dbhandler").events
5+
;
46

57
module.exports = new Clapp.Command({
68
name: "get-lobby",
79
desc: "Gets the current lobby name and password sent to you on a DM",
810
fn: (argv, context) => {
911
return new Promise((fulfill, reject) => {
10-
let lobby = context.dotaHandler.currentLobbyName;
11-
let pass = context.dotaHandler.currentLobbyPassword;
12+
db.events.get(argv.args.event).then(event => {
13+
if (event === null) {
14+
fulfill("Error: the specified event `" + argv.args.event + "` doesn't exist.");
15+
} else {
16+
db.getLobbyBotId(event).then(botID => {
17+
let details = context.dotaHandler.getLobbyDetails(botID);
1218

13-
if (lobby !== null) {
14-
context.msg.author.sendMessage(
15-
"Hello! Here's the information you requested:\n\n" +
19+
if (details === null) {
20+
fulfill("The Dota bot is not in a lobby.");
21+
} else {
22+
context.msg.author.sendMessage(
23+
"Hello! Here's the information you requested:\n\n" +
1624

17-
"- **Current lobby name**: `" + lobby + "`\n" +
18-
"- **Current lobby password**: `" + pass + "`"
19-
).then(() => {
20-
fulfill("The information you requested was sent to you in a DM.");
21-
}).catch(reject);
22-
} else {
23-
fulfill("The Dota bot is not in a lobby.");
24-
}
25+
"- **Lobby name**: `" + details.name + "`\n" +
26+
"- **Lobby password**: `" + details.password + "`"
27+
).then(() => {
28+
fulfill("The information you requested was sent to you in a DM.");
29+
}).catch(reject);
30+
}
31+
}).catch(reject);
32+
}
33+
}).catch(reject);
2534
});
26-
}
35+
},
36+
args: [
37+
require("./shared/event")
38+
]
2739
});

lib/commands/admin/kick.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ module.exports = new Clapp.Command({
2020
.then(() => {
2121
fulfill(user + " has been successfully kicked from " +
2222
"the event `" + argv.args.id + "`.\n" +
23-
"Please note that they are able to rejoin it at any time. To " +
24-
"prevent them from doing so, use the `blacklist-add` command.");
23+
"Please note that they are able to rejoin it at any" +
24+
"time. To prevent them from doing so, use the" +
25+
" `blacklist-add` command.");
2526
}).catch(reject);
2627
} else {
2728
fulfill("Error: the specified user isn't attending the specified " +

lib/commands/admin/remove-event.js

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22

33
const Clapp = require('../../modules/clapp-discord/index');
4-
const cfg = require('../../../config');
54
const db = require('../../modules/dbhandler/index').events;
65

76
module.exports = new Clapp.Command({
@@ -13,27 +12,26 @@ module.exports = new Clapp.Command({
1312
if (event !== null) {
1413
let eventName = event.name;
1514
let deleteSummaryPromise = context.summaryHandler.deleteSummary(event);
16-
let deleteEventPromise = event.deleteEvent();
17-
let closeLobbyPromise = new Promise((fulfill, reject) => {
18-
// If the event has an active lobby, close it
19-
if (
20-
context.dotaHandler.currentLobbyEvent &&
21-
context.dotaHandler.currentLobbyEvent.id === event.id
22-
) {
23-
context.dotaHandler.closeLobby(true).then(fulfill).catch(reject);
24-
} else {
25-
fulfill();
26-
}
15+
let closeLobbyPromise = new Promise((fulfill2, reject2) => {
16+
db.getLobbyBotId(event)
17+
.then(botID => {
18+
// If the bot exists and is in a lobby, close it. Otherwise fulfill.
19+
if (botID && context.dotaHandler.isBotInLobby(botID)) {
20+
context.dotaHandler.closeLobby(botID, true)
21+
.then(fulfill2)
22+
.catch(reject2);
23+
} else {
24+
fulfill2();
25+
}
26+
})
27+
.catch(reject2);
2728
});
2829

29-
Promise.all(
30-
[deleteSummaryPromise, deleteEventPromise, closeLobbyPromise]
31-
).then(() => {
32-
fulfill("The event `" + eventName+ "` was successfully deleted.");
33-
}).catch(err => {
34-
console.error(err);
35-
fulfill("Sorry, an internal error occurred. Please talk to my author.");
36-
});
30+
Promise.all([deleteSummaryPromise, closeLobbyPromise])
31+
.then(() => event.deleteEvent())
32+
.then(() => {
33+
fulfill("The event `" + eventName + "` was successfully deleted.");
34+
}).catch(reject);
3735
} else {
3836
fulfill("Error: the specified event `" + argv.args.id + "` doesn't exist.");
3937
}

lib/commands/admin/shared/event.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const Clapp = require("../../../modules/clapp-discord/index");
2+
3+
module.exports = new Clapp.Argument({
4+
name: "event",
5+
desc: "The ID of the event",
6+
type: "number",
7+
required: true
8+
});

lib/commands/admin/status.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"use strict";
2+
3+
const Clapp = require("../../modules/clapp-discord");
4+
5+
module.exports = new Clapp.Command({
6+
name: "status",
7+
desc: "Gets information about the Discord bot and Steam bots sent to you on a DM",
8+
fn: (argv, context) => {
9+
return new Promise((fulfill, reject) => {
10+
let bots = context.dotaHandler.bots;
11+
12+
let msg = "Hello! Here's the bot status information:\n\n";
13+
14+
let genValueString = (key, value, newline = true) => {
15+
return `- **${key}**: \`${value}\`${newline ? "\n" : ""}`;
16+
};
17+
18+
msg += genValueString(
19+
"Uptime",
20+
Math.floor((context.summaryHandler.bot.uptime / 1000) / 60) + " minutes"
21+
);
22+
23+
for (let i = 0; i < bots.length; i++) {
24+
let dotaClient = bots[i].dota.client;
25+
26+
msg += genValueString(
27+
`Bot #${dotaClient.botId}`,
28+
context.dotaHandler.isBotInLobby(dotaClient.botId)
29+
? `In lobby: ${dotaClient.currentLobby.name} ` +
30+
`(Event #${dotaClient.currentLobby.event.id})`
31+
: `Not in lobby`,
32+
i !== bots.length
33+
);
34+
}
35+
36+
context.msg.author.sendMessage(msg)
37+
.then(() => fulfill("The information you requested was sent to you in a DM."))
38+
.catch(reject);
39+
});
40+
}
41+
});

0 commit comments

Comments
 (0)