koishi-plugin-tmp-bot 1.16.1 → 1.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/evmOpenApi.js +71 -0
- package/lib/api/truckersMpApi.js +115 -0
- package/lib/api/truckersMpMapApi.js +26 -0
- package/lib/api/truckyAppApi.js +49 -0
- package/package.json +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const BASE_API = 'https://open-api.vtcm.link'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
/**
|
|
5
|
+
* 查询服务器列表
|
|
6
|
+
*/
|
|
7
|
+
async serverList (http) {
|
|
8
|
+
let result = null
|
|
9
|
+
try {
|
|
10
|
+
result = await http.get(`${BASE_API}/server/list`)
|
|
11
|
+
} catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 拼接返回数据
|
|
18
|
+
let data = {
|
|
19
|
+
error: result.code !== 200
|
|
20
|
+
}
|
|
21
|
+
if (!data.error) {
|
|
22
|
+
data.data = result.data
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return data
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* 查询在线玩家
|
|
29
|
+
*/
|
|
30
|
+
async mapPlayerList(http, serverId, ax, ay, bx, by) {
|
|
31
|
+
let result = null
|
|
32
|
+
try {
|
|
33
|
+
result = await http.get(`${BASE_API}/map/playerList?aAxisX=${ax}&aAxisY=${ay}&bAxisX=${bx}&bAxisY=${by}&serverId=${serverId}`)
|
|
34
|
+
} catch {
|
|
35
|
+
return {
|
|
36
|
+
error: true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 拼接返回数据
|
|
41
|
+
let data = {
|
|
42
|
+
error: result.code !== 200
|
|
43
|
+
}
|
|
44
|
+
if (!data.error) {
|
|
45
|
+
data.data = result.data
|
|
46
|
+
}
|
|
47
|
+
return data
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 查询玩家信息
|
|
51
|
+
*/
|
|
52
|
+
async playerInfo (http, tmpId) {
|
|
53
|
+
let result = null
|
|
54
|
+
try {
|
|
55
|
+
result = await http.get(`${BASE_API}/player/info?tmpId=${tmpId}`)
|
|
56
|
+
} catch {
|
|
57
|
+
return {
|
|
58
|
+
error: true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 拼接返回数据
|
|
63
|
+
let data = {
|
|
64
|
+
error: result.code !== 200
|
|
65
|
+
}
|
|
66
|
+
if (!data.error) {
|
|
67
|
+
data.data = result.data
|
|
68
|
+
}
|
|
69
|
+
return data
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const BASE_API = 'https://api.truckersmp.com/v2'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
/**
|
|
5
|
+
* 查询玩家信息
|
|
6
|
+
*/
|
|
7
|
+
async player (http, tmpId) {
|
|
8
|
+
let result = null
|
|
9
|
+
try {
|
|
10
|
+
result = await http.get(`${BASE_API}/player/${tmpId}`)
|
|
11
|
+
} catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 拼接返回数据
|
|
18
|
+
let data = {
|
|
19
|
+
error: JSON.parse(result.error)
|
|
20
|
+
}
|
|
21
|
+
if (!data.error) {
|
|
22
|
+
data.data = result.response
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return data
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* 查询服务器列表
|
|
29
|
+
*/
|
|
30
|
+
async servers (http) {
|
|
31
|
+
let result = null
|
|
32
|
+
try {
|
|
33
|
+
result = await http.get(`${BASE_API}/servers`)
|
|
34
|
+
} catch {
|
|
35
|
+
return {
|
|
36
|
+
error: true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 拼接返回数据
|
|
41
|
+
let data = {
|
|
42
|
+
error: JSON.parse(result.error)
|
|
43
|
+
}
|
|
44
|
+
if (!data.error) {
|
|
45
|
+
data.data = result.response
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return data
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* 查询玩家封禁信息
|
|
52
|
+
*/
|
|
53
|
+
async bans (http, tmpId) {
|
|
54
|
+
let result = null
|
|
55
|
+
try {
|
|
56
|
+
result = await http.get(`${BASE_API}/bans/${tmpId}`)
|
|
57
|
+
} catch {
|
|
58
|
+
return {
|
|
59
|
+
error: true
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 拼接返回数据
|
|
64
|
+
let data = {
|
|
65
|
+
error: JSON.parse(result.error)
|
|
66
|
+
}
|
|
67
|
+
if (!data.error) {
|
|
68
|
+
data.data = result.response
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return data
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* 游戏版本
|
|
75
|
+
*/
|
|
76
|
+
async version (http) {
|
|
77
|
+
let result = null
|
|
78
|
+
try {
|
|
79
|
+
result = await http.get(`${BASE_API}/version`)
|
|
80
|
+
} catch {
|
|
81
|
+
return {
|
|
82
|
+
error: true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 拼接返回数据
|
|
87
|
+
return {
|
|
88
|
+
error: false,
|
|
89
|
+
data: result
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* 查询车队成员信息
|
|
94
|
+
*/
|
|
95
|
+
async vtcMember (http, vtcId, memberId) {
|
|
96
|
+
let result = null
|
|
97
|
+
try {
|
|
98
|
+
result = await http.get(`${BASE_API}/vtc/${vtcId}/member/${memberId}`)
|
|
99
|
+
} catch {
|
|
100
|
+
return {
|
|
101
|
+
error: true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 拼接返回数据
|
|
106
|
+
let data = {
|
|
107
|
+
error: JSON.parse(result.error)
|
|
108
|
+
}
|
|
109
|
+
if (!data.error) {
|
|
110
|
+
data.data = result.response
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return data
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const BASE_API = 'https://tracker.ets2map.com'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
/**
|
|
5
|
+
* 区域查询玩家
|
|
6
|
+
*/
|
|
7
|
+
async area (http, serverId, x1, y1, x2, y2) {
|
|
8
|
+
let result = null
|
|
9
|
+
try {
|
|
10
|
+
result = await http.get(`${BASE_API}/v3/area?x1=${x1}&y1=${y1}&x2=${x2}&y2=${y2}&server=${serverId}`)
|
|
11
|
+
} catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 拼接返回数据
|
|
18
|
+
let data = {
|
|
19
|
+
error: !result || !result.Success
|
|
20
|
+
}
|
|
21
|
+
if (!data.error) {
|
|
22
|
+
data.data = result.Data
|
|
23
|
+
}
|
|
24
|
+
return data
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const BASE_API_V3 = 'https://api.truckyapp.com/v3'
|
|
2
|
+
const BASE_API_V2 = 'https://api.truckyapp.com/v2'
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
/**
|
|
6
|
+
* 查询线上信息
|
|
7
|
+
*/
|
|
8
|
+
async online (http, tmpId) {
|
|
9
|
+
let result = null
|
|
10
|
+
try {
|
|
11
|
+
result = await http.get(`${BASE_API_V3}/map/online?playerID=${tmpId}`)
|
|
12
|
+
} catch {
|
|
13
|
+
return {
|
|
14
|
+
error: true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 拼接返回数据
|
|
19
|
+
let data = {
|
|
20
|
+
error: !result || !result.response || result.response.error
|
|
21
|
+
}
|
|
22
|
+
if (!data.error) {
|
|
23
|
+
data.data = result.response
|
|
24
|
+
}
|
|
25
|
+
return data
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* 查询热门交通数据
|
|
29
|
+
*/
|
|
30
|
+
async trafficTop (http, serverName) {
|
|
31
|
+
let result = null
|
|
32
|
+
try {
|
|
33
|
+
result = await http.get(`${BASE_API_V2}/traffic/top?game=ets2&server=${serverName}`)
|
|
34
|
+
} catch {
|
|
35
|
+
return {
|
|
36
|
+
error: true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 拼接返回数据
|
|
41
|
+
let data = {
|
|
42
|
+
error: !result || !result.response || result.response.length <= 0
|
|
43
|
+
}
|
|
44
|
+
if (!data.error) {
|
|
45
|
+
data.data = result.response
|
|
46
|
+
}
|
|
47
|
+
return data
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-tmp-bot",
|
|
3
3
|
"description": "欧洲卡车模拟2 TMP查询插件,不会部署的可以直接使用此机器人->QQ:3523283907",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",
|