/
get-player-list.js
109 lines (82 loc) · 2.32 KB
/
get-player-list.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module.exports = {
friendlyName: 'Get player list',
description: 'Gets a list of persistent player profiles',
cacheable: false,
sync: false,
inputs: {
ip: {
friendlyName: 'IP address',
type: 'string',
description: 'IP of the server to send a request to',
required: true,
example: "192.168.0.1",
},
port: {
type: 'number',
description: "Port of the server to send a request.",
extendedDescription: "Make sure this is the port for the web server, not telnet or ...",
required: true,
example: "8082",
},
authName: {
type: 'string',
description: 'Authorization name to send with the request',
example: "csmm",
whereToGet: {
description: 'Set in webpermission.xml or with webtokens telnet command'
}
},
authToken: {
type: 'string',
description: 'Authorization token to send with the request',
example: "EOGHZANOIZEAHZFUR93573298539242F3NG",
whereToGet: {
description: 'Set in webpermission.xml or with webtokens telnet command'
}
},
},
exits: {
success: {
variableName: 'result',
description: 'Done.',
},
connectionRefused: {
variableName: 'error',
description: 'Server refused the request (usually means server offline)'
},
unauthorized: {
variableName: 'error',
description: 'Not authorized to do this request',
extendedDescription: 'Server rejected the auth info sent. Please check if the server has auth name and token configured'
},
error: {
description: "An unknown error occurred"
}
},
fn: function(inputs, exits) {
const doRequest = require('machine').build(require('./send-request.js'))
doRequest({
ip: inputs.ip,
port: inputs.port,
authName: inputs.authName,
authToken: inputs.authToken,
apiModule: "getplayerlist",
extraqs: {
rowsperpage: 99999
}
}).exec({
success: function(result) {
return exits.success(result)
},
connectionRefused: function(error) {
return exits.connectionRefused(error)
},
unauthorized: function(error) {
return exits.unauthorized(error)
},
error: function(error) {
return exits.error(error)
}
})
},
};