-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dota-feature-multiple-steam-bots'
Squashed commit of the following: commit ff26b5d Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Sat Jan 14 17:15:09 2017 +0100 Works apparently. commit bed8095 Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Fri Jan 13 11:34:17 2017 +0100 small progress commit 07a80e5 Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Thu Jan 12 20:47:31 2017 +0100 Fixed some things + status command (untested) commit 5594b93 Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Thu Jan 12 14:06:28 2017 +0100 Seems to work now commit e864b89 Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Thu Jan 12 13:26:51 2017 +0100 Getting an error on lobby creation commit 100c4df Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Wed Jan 11 20:41:56 2017 +0100 Still a wip... commit 64bb4e1 Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Wed Jan 11 13:30:49 2017 +0100 Forgot to upload the next version sql changes commit 977b5cb Author: Pablo Rodríguez <pabloviolin8@gmail.com> 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 <pabloviolin8@gmail.com> 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 <pabloviolin8@gmail.com> Date: Sat Jan 7 14:22:57 2017 +0100 Still a work in progress Rewriting the dotahandler module. commit 5d1aa84 Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Fri Jan 6 21:38:12 2017 +0100 Doesn't work so far commit a95b25e Author: Pablo Rodríguez <pabloviolin8@gmail.com> Date: Fri Jan 6 13:28:27 2017 +0100 Changed scripts to work with multiple bots
- Loading branch information
1 parent
4b005fd
commit 021bae7
Showing
22 changed files
with
1,288 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
"use strict"; | ||
|
||
const Clapp = require('../../modules/clapp-discord/index'); | ||
const Clapp = require("../../modules/clapp-discord") | ||
, ECloseLobbyError = require("../../structures/enums/ECloseLobbyError") | ||
, db = require("../../modules/dbhandler").events | ||
; | ||
|
||
module.exports = new Clapp.Command({ | ||
name: "force-lobby-start", | ||
desc: "Forces the current lobby to start, even if there aren't enough players.", | ||
desc: "Forces the lobby for the specified event to start, even if there aren't enough players.", | ||
fn: (argv, context) => { | ||
return new Promise((fulfill, reject) => { | ||
context.dotaHandler.forceStart().catch(reject); | ||
fulfill("Forced current lobby start"); | ||
db.events.get(argv.args.event).then(event => { | ||
if (event !== null) { | ||
db.events.getLobbyBotId(event) | ||
.then(botID => context.dotaHandler.forceLobbyStart(botID)) | ||
.then(() => fulfill(`Forced lobby start for the event ${event.id}.`)) | ||
.catch(reject); | ||
} else { | ||
fulfill("Error: the specified event `" + argv.args.event + "` doesn't exist."); | ||
} | ||
}).catch(reject); | ||
}); | ||
} | ||
}, | ||
args: [ | ||
require("./shared/event") | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
"use strict"; | ||
|
||
const Clapp = require('../../modules/clapp-discord/index'); | ||
const Clapp = require("../../modules/clapp-discord") | ||
, db = require("../../modules/dbhandler").events | ||
; | ||
|
||
module.exports = new Clapp.Command({ | ||
name: "get-lobby", | ||
desc: "Gets the current lobby name and password sent to you on a DM", | ||
fn: (argv, context) => { | ||
return new Promise((fulfill, reject) => { | ||
let lobby = context.dotaHandler.currentLobbyName; | ||
let pass = context.dotaHandler.currentLobbyPassword; | ||
db.events.get(argv.args.event).then(event => { | ||
if (event === null) { | ||
fulfill("Error: the specified event `" + argv.args.event + "` doesn't exist."); | ||
} else { | ||
db.getLobbyBotId(event).then(botID => { | ||
let details = context.dotaHandler.getLobbyDetails(botID); | ||
|
||
if (lobby !== null) { | ||
context.msg.author.sendMessage( | ||
"Hello! Here's the information you requested:\n\n" + | ||
if (details === null) { | ||
fulfill("The Dota bot is not in a lobby."); | ||
} else { | ||
context.msg.author.sendMessage( | ||
"Hello! Here's the information you requested:\n\n" + | ||
|
||
"- **Current lobby name**: `" + lobby + "`\n" + | ||
"- **Current lobby password**: `" + pass + "`" | ||
).then(() => { | ||
fulfill("The information you requested was sent to you in a DM."); | ||
}).catch(reject); | ||
} else { | ||
fulfill("The Dota bot is not in a lobby."); | ||
} | ||
"- **Lobby name**: `" + details.name + "`\n" + | ||
"- **Lobby password**: `" + details.password + "`" | ||
).then(() => { | ||
fulfill("The information you requested was sent to you in a DM."); | ||
}).catch(reject); | ||
} | ||
}).catch(reject); | ||
} | ||
}).catch(reject); | ||
}); | ||
} | ||
}, | ||
args: [ | ||
require("./shared/event") | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Clapp = require("../../../modules/clapp-discord/index"); | ||
|
||
module.exports = new Clapp.Argument({ | ||
name: "event", | ||
desc: "The ID of the event", | ||
type: "number", | ||
required: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use strict"; | ||
|
||
const Clapp = require("../../modules/clapp-discord"); | ||
|
||
module.exports = new Clapp.Command({ | ||
name: "status", | ||
desc: "Gets information about the Discord bot and Steam bots sent to you on a DM", | ||
fn: (argv, context) => { | ||
return new Promise((fulfill, reject) => { | ||
let bots = context.dotaHandler.bots; | ||
|
||
let msg = "Hello! Here's the bot status information:\n\n"; | ||
|
||
let genValueString = (key, value, newline = true) => { | ||
return `- **${key}**: \`${value}\`${newline ? "\n" : ""}`; | ||
}; | ||
|
||
msg += genValueString( | ||
"Uptime", | ||
Math.floor((context.summaryHandler.bot.uptime / 1000) / 60) + " minutes" | ||
); | ||
|
||
for (let i = 0; i < bots.length; i++) { | ||
let dotaClient = bots[i].dota.client; | ||
|
||
msg += genValueString( | ||
`Bot #${dotaClient.botId}`, | ||
context.dotaHandler.isBotInLobby(dotaClient.botId) | ||
? `In lobby: ${dotaClient.currentLobby.name} ` + | ||
`(Event #${dotaClient.currentLobby.event.id})` | ||
: `Not in lobby`, | ||
i !== bots.length | ||
); | ||
} | ||
|
||
context.msg.author.sendMessage(msg) | ||
.then(() => fulfill("The information you requested was sent to you in a DM.")) | ||
.catch(reject); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,47 @@ | ||
"use strict"; | ||
|
||
const Clapp = require('../../modules/clapp-discord/index') | ||
, cfg = require('../../../config') | ||
, db = require('../../modules/dbhandler'); | ||
, db = require('../../modules/dbhandler').events | ||
; | ||
|
||
module.exports = new Clapp.Command({ | ||
name: "resend-invite", | ||
desc: "Resends an invite to the current lobby. You need to have confirmed attendance for" + | ||
" this to work.", | ||
desc: "Resends an invite to the specified event's lobby. You need to have confirmed" + | ||
" attendance for this to work.", | ||
fn: (argv, context) => { | ||
return new Promise((fulfill, reject) => { | ||
context.dotaHandler.currentLobbyEvent.getConfirms().then(people => { | ||
let confirmed = false; | ||
db.get(argv.args.id).then(event => { | ||
if (event !== null) { | ||
event.getConfirms().then(people => { | ||
let confirmed = false; | ||
|
||
for (let i = 0; i < people.confirmed.length; i++) { | ||
let discordID = people.confirmed[i]; | ||
for (let i = 0; i < people.confirmed.length; i++) { | ||
let discordID = people.confirmed[i]; | ||
|
||
if (context.msg.author.id === discordID) { | ||
confirmed = true; | ||
} | ||
} | ||
if (context.msg.author.id === discordID) { | ||
confirmed = true; | ||
} | ||
} | ||
|
||
if (confirmed) { | ||
context.dotaHandler.invite(context.msg.author.id).then(() => { | ||
fulfill("The invite has been resent. Accept it inside Dota 2."); | ||
if (confirmed) { | ||
db.events.getLobbyBotId().then(botID => context.dotaHandler.invite( | ||
botID, context.msg.author.id | ||
)).then(() => { | ||
fulfill("The invite has been resent. Accept it inside Dota 2."); | ||
}).catch(reject); | ||
} else { | ||
fulfill("Error: you haven't confirmed attendance to the event `#" + | ||
context.dotaHandler.currentLobbyEvent.id + "`.\n" + | ||
"You need to do so before requesting to be invited to the lobby"); | ||
} | ||
}).catch(reject); | ||
} else { | ||
fulfill("Error: you haven't confirmed attendance to the event `#" + | ||
context.dotaHandler.currentLobbyEvent.id + "`.\n" + | ||
"You need to do so before requesting to be invited to the lobby"); | ||
fulfill("Event #`" + argv.args.id + "` does not exist"); | ||
} | ||
}).catch(reject); | ||
}); | ||
} | ||
}, | ||
args: [ | ||
require("./shared/id") | ||
] | ||
}); |
Oops, something went wrong.