forked from starwolfy/steam-ts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
launchteamspeak.js
48 lines (41 loc) · 1.83 KB
/
launchteamspeak.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module.exports = function(config, callback) {
// Only use teamspeakClient in keepalive.js, so we replace the already existing client when TeamSpeak goes down.
var async = require('async'),
TeamSpeakClient = require("node-teamspeak"),
util = require("util");
async.waterfall([
function (callback) {
console.log("Trying to connect to the TeamSpeak server...");
var teamspeakClient = new TeamSpeakClient(config.ts_ip, config.q_port);
teamspeakClient.send("login", {client_login_name: config.q_username, client_login_password: config.q_password}, function (err) {
if (typeof err !== "undefined") {
callback(err);
} else {
callback(null, teamspeakClient)
}
});
},
// Combined server selection & bot nickname into one command as from build 1536564584 this appears to be required
// Should solve { id: 513, msg: 'nickname is already in use' } referencing bot's own name
function (teamspeakClient, callback) {
console.log("Logged into the query with credentials.");
teamspeakClient.send("use", {sid: config.q_vserverid, client_nickname: config.bot_nickname}, function (err) {
if (typeof err !== "undefined") {
callback(err);
} else {
console.log(`Using virtual server ${config.q_vserverid} now.`);
console.log(`Bot connect as: ${config.bot_nickname}`);
callback(null, teamspeakClient);
}
})
},
],
function (err, results) {
// results = teamspeakClient
if (err != null) {
callback(err);
} else {
callback(null, results);
}
});
};