koishi-plugin-tmp-bot 1.16.3 → 1.16.4
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.d.ts +18 -0
- package/lib/api/evmOpenApi.js +67 -69
- package/lib/api/truckersMpApi.d.ts +34 -0
- package/lib/api/truckersMpApi.js +108 -113
- package/lib/api/truckersMpMapApi.d.ts +6 -0
- package/lib/api/truckersMpMapApi.js +23 -24
- package/lib/api/truckyAppApi.d.ts +12 -0
- package/lib/api/truckyAppApi.js +46 -47
- package/lib/command/tmpBind.d.ts +2 -0
- package/lib/command/tmpBind.js +13 -17
- package/lib/command/tmpDlcMap.d.ts +3 -0
- package/lib/command/tmpDlcMap.js +27 -29
- package/lib/command/tmpPosition.d.ts +3 -0
- package/lib/command/tmpPosition.js +90 -101
- package/lib/command/tmpQuery/tmpQuery.d.ts +2 -0
- package/lib/command/tmpQuery/tmpQuery.js +9 -10
- package/lib/command/tmpQuery/tmpQueryImg.d.ts +3 -0
- package/lib/command/tmpQuery/tmpQueryImg.js +88 -96
- package/lib/command/tmpQuery/tmpQueryText.d.ts +2 -0
- package/lib/command/tmpQuery/tmpQueryText.js +78 -82
- package/lib/command/tmpServer.d.ts +2 -0
- package/lib/command/tmpServer.js +31 -34
- package/lib/command/tmpTraffic/tmpTraffic.d.ts +2 -0
- package/lib/command/tmpTraffic/tmpTraffic.js +9 -10
- package/lib/command/tmpTraffic/tmpTrafficMap.d.ts +3 -0
- package/lib/command/tmpTraffic/tmpTrafficMap.js +101 -110
- package/lib/command/tmpTraffic/tmpTrafficText.d.ts +2 -0
- package/lib/command/tmpTraffic/tmpTrafficText.js +41 -49
- package/lib/command/tmpVersion.d.ts +2 -0
- package/lib/command/tmpVersion.js +12 -14
- package/lib/database/guildBind.d.ts +15 -0
- package/lib/database/guildBind.js +39 -40
- package/lib/database/model.d.ts +2 -0
- package/lib/database/model.js +55 -56
- package/lib/database/translateCache.d.ts +14 -0
- package/lib/database/translateCache.js +29 -31
- package/lib/resource/package/leaflet/heatmap.min.js +9 -0
- package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -0
- package/lib/resource/package/leaflet/leaflet.min.js +1 -0
- package/lib/util/baiduTranslate.d.ts +2 -0
- package/lib/util/baiduTranslate.js +28 -35
- package/lib/util/common.d.ts +1 -0
- package/lib/util/common.js +4 -4
- package/lib/util/constant.d.ts +4 -0
- package/lib/util/constant.js +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 查询服务器列表
|
|
3
|
+
*/
|
|
4
|
+
export function serverList(http: any): Promise<{
|
|
5
|
+
error: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* 查询在线玩家
|
|
9
|
+
*/
|
|
10
|
+
export function mapPlayerList(http: any, serverId: any, ax: any, ay: any, bx: any, by: any): Promise<{
|
|
11
|
+
error: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* 查询玩家信息
|
|
15
|
+
*/
|
|
16
|
+
export function playerInfo(http: any, tmpId: any): Promise<{
|
|
17
|
+
error: boolean;
|
|
18
|
+
}>;
|
package/lib/api/evmOpenApi.js
CHANGED
|
@@ -1,71 +1,69 @@
|
|
|
1
|
-
const BASE_API = 'https://open-api.vtcm.link'
|
|
2
|
-
|
|
1
|
+
const BASE_API = 'https://open-api.vtcm.link';
|
|
3
2
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 查询服务器列表
|
|
5
|
+
*/
|
|
6
|
+
async serverList(http) {
|
|
7
|
+
let result = null;
|
|
8
|
+
try {
|
|
9
|
+
result = await http.get(`${BASE_API}/server/list`);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// 拼接返回数据
|
|
17
|
+
let data = {
|
|
18
|
+
error: result.code !== 200
|
|
19
|
+
};
|
|
20
|
+
if (!data.error) {
|
|
21
|
+
data.data = result.data;
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* 查询在线玩家
|
|
27
|
+
*/
|
|
28
|
+
async mapPlayerList(http, serverId, ax, ay, bx, by) {
|
|
29
|
+
let result = null;
|
|
30
|
+
try {
|
|
31
|
+
result = await http.get(`${BASE_API}/map/playerList?aAxisX=${ax}&aAxisY=${ay}&bAxisX=${bx}&bAxisY=${by}&serverId=${serverId}`);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return {
|
|
35
|
+
error: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// 拼接返回数据
|
|
39
|
+
let data = {
|
|
40
|
+
error: result.code !== 200
|
|
41
|
+
};
|
|
42
|
+
if (!data.error) {
|
|
43
|
+
data.data = result.data;
|
|
44
|
+
}
|
|
45
|
+
return data;
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* 查询玩家信息
|
|
49
|
+
*/
|
|
50
|
+
async playerInfo(http, tmpId) {
|
|
51
|
+
let result = null;
|
|
52
|
+
try {
|
|
53
|
+
result = await http.get(`${BASE_API}/player/info?tmpId=${tmpId}`);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return {
|
|
57
|
+
error: true
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// 拼接返回数据
|
|
61
|
+
let data = {
|
|
62
|
+
error: result.code !== 200
|
|
63
|
+
};
|
|
64
|
+
if (!data.error) {
|
|
65
|
+
data.data = result.data;
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
15
68
|
}
|
|
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
|
-
}
|
|
69
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 查询玩家信息
|
|
3
|
+
*/
|
|
4
|
+
export function player(http: any, tmpId: any): Promise<{
|
|
5
|
+
error: any;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* 查询服务器列表
|
|
9
|
+
*/
|
|
10
|
+
export function servers(http: any): Promise<{
|
|
11
|
+
error: any;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* 查询玩家封禁信息
|
|
15
|
+
*/
|
|
16
|
+
export function bans(http: any, tmpId: any): Promise<{
|
|
17
|
+
error: any;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* 游戏版本
|
|
21
|
+
*/
|
|
22
|
+
export function version(http: any): Promise<{
|
|
23
|
+
error: boolean;
|
|
24
|
+
data?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
error: boolean;
|
|
27
|
+
data: any;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* 查询车队成员信息
|
|
31
|
+
*/
|
|
32
|
+
export function vtcMember(http: any, vtcId: any, memberId: any): Promise<{
|
|
33
|
+
error: any;
|
|
34
|
+
}>;
|
package/lib/api/truckersMpApi.js
CHANGED
|
@@ -1,115 +1,110 @@
|
|
|
1
|
-
const BASE_API = 'https://api.truckersmp.com/v2'
|
|
2
|
-
|
|
1
|
+
const BASE_API = 'https://api.truckersmp.com/v2';
|
|
3
2
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 查询玩家信息
|
|
5
|
+
*/
|
|
6
|
+
async player(http, tmpId) {
|
|
7
|
+
let result = null;
|
|
8
|
+
try {
|
|
9
|
+
result = await http.get(`${BASE_API}/player/${tmpId}`);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// 拼接返回数据
|
|
17
|
+
let data = {
|
|
18
|
+
error: JSON.parse(result.error)
|
|
19
|
+
};
|
|
20
|
+
if (!data.error) {
|
|
21
|
+
data.data = result.response;
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* 查询服务器列表
|
|
27
|
+
*/
|
|
28
|
+
async servers(http) {
|
|
29
|
+
let result = null;
|
|
30
|
+
try {
|
|
31
|
+
result = await http.get(`${BASE_API}/servers`);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return {
|
|
35
|
+
error: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// 拼接返回数据
|
|
39
|
+
let data = {
|
|
40
|
+
error: JSON.parse(result.error)
|
|
41
|
+
};
|
|
42
|
+
if (!data.error) {
|
|
43
|
+
data.data = result.response;
|
|
44
|
+
}
|
|
45
|
+
return data;
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* 查询玩家封禁信息
|
|
49
|
+
*/
|
|
50
|
+
async bans(http, tmpId) {
|
|
51
|
+
let result = null;
|
|
52
|
+
try {
|
|
53
|
+
result = await http.get(`${BASE_API}/bans/${tmpId}`);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return {
|
|
57
|
+
error: true
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// 拼接返回数据
|
|
61
|
+
let data = {
|
|
62
|
+
error: JSON.parse(result.error)
|
|
63
|
+
};
|
|
64
|
+
if (!data.error) {
|
|
65
|
+
data.data = result.response;
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* 游戏版本
|
|
71
|
+
*/
|
|
72
|
+
async version(http) {
|
|
73
|
+
let result = null;
|
|
74
|
+
try {
|
|
75
|
+
result = await http.get(`${BASE_API}/version`);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return {
|
|
79
|
+
error: true
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// 拼接返回数据
|
|
83
|
+
return {
|
|
84
|
+
error: false,
|
|
85
|
+
data: result
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* 查询车队成员信息
|
|
90
|
+
*/
|
|
91
|
+
async vtcMember(http, vtcId, memberId) {
|
|
92
|
+
let result = null;
|
|
93
|
+
try {
|
|
94
|
+
result = await http.get(`${BASE_API}/vtc/${vtcId}/member/${memberId}`);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return {
|
|
98
|
+
error: true
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// 拼接返回数据
|
|
102
|
+
let data = {
|
|
103
|
+
error: JSON.parse(result.error)
|
|
104
|
+
};
|
|
105
|
+
if (!data.error) {
|
|
106
|
+
data.data = result.response;
|
|
107
|
+
}
|
|
108
|
+
return data;
|
|
15
109
|
}
|
|
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
|
-
}
|
|
110
|
+
};
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
const BASE_API = 'https://tracker.ets2map.com'
|
|
2
|
-
|
|
1
|
+
const BASE_API = 'https://tracker.ets2map.com';
|
|
3
2
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 区域查询玩家
|
|
5
|
+
*/
|
|
6
|
+
async area(http, serverId, x1, y1, x2, y2) {
|
|
7
|
+
let result = null;
|
|
8
|
+
try {
|
|
9
|
+
result = await http.get(`${BASE_API}/v3/area?x1=${x1}&y1=${y1}&x2=${x2}&y2=${y2}&server=${serverId}`);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {
|
|
13
|
+
error: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// 拼接返回数据
|
|
17
|
+
let data = {
|
|
18
|
+
error: !result || !result.Success
|
|
19
|
+
};
|
|
20
|
+
if (!data.error) {
|
|
21
|
+
data.data = result.Data;
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
15
24
|
}
|
|
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
|
-
}
|
|
25
|
+
};
|
package/lib/api/truckyAppApi.js
CHANGED
|
@@ -1,49 +1,48 @@
|
|
|
1
|
-
const BASE_API_V3 = 'https://api.truckyapp.com/v3'
|
|
2
|
-
const BASE_API_V2 = 'https://api.truckyapp.com/v2'
|
|
3
|
-
|
|
1
|
+
const BASE_API_V3 = 'https://api.truckyapp.com/v3';
|
|
2
|
+
const BASE_API_V2 = 'https://api.truckyapp.com/v2';
|
|
4
3
|
module.exports = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 查询线上信息
|
|
6
|
+
*/
|
|
7
|
+
async online(http, tmpId) {
|
|
8
|
+
let result = null;
|
|
9
|
+
try {
|
|
10
|
+
result = await http.get(`${BASE_API_V3}/map/online?playerID=${tmpId}`);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return {
|
|
14
|
+
error: true
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
// 拼接返回数据
|
|
18
|
+
let data = {
|
|
19
|
+
error: !result || !result.response || result.response.error
|
|
20
|
+
};
|
|
21
|
+
if (!data.error) {
|
|
22
|
+
data.data = result.response;
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* 查询热门交通数据
|
|
28
|
+
*/
|
|
29
|
+
async trafficTop(http, serverName) {
|
|
30
|
+
let result = null;
|
|
31
|
+
try {
|
|
32
|
+
result = await http.get(`${BASE_API_V2}/traffic/top?game=ets2&server=${serverName}`);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return {
|
|
36
|
+
error: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// 拼接返回数据
|
|
40
|
+
let data = {
|
|
41
|
+
error: !result || !result.response || result.response.length <= 0
|
|
42
|
+
};
|
|
43
|
+
if (!data.error) {
|
|
44
|
+
data.data = result.response;
|
|
45
|
+
}
|
|
46
|
+
return data;
|
|
16
47
|
}
|
|
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
|
-
}
|
|
48
|
+
};
|
package/lib/command/tmpBind.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
const guildBind = require('../database/guildBind')
|
|
1
|
+
const guildBind = require('../database/guildBind');
|
|
2
2
|
const truckersMpApi = require("../api/truckersMpApi");
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* 绑定 TMP ID
|
|
6
5
|
*/
|
|
7
6
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return `绑定成功 ( ${playerInfo.data.name} )`
|
|
22
|
-
}
|
|
7
|
+
if (!tmpId || isNaN(tmpId)) {
|
|
8
|
+
return `请输入正确的玩家编号`;
|
|
9
|
+
}
|
|
10
|
+
// 查询玩家信息
|
|
11
|
+
let playerInfo = await truckersMpApi.player(ctx.http, tmpId);
|
|
12
|
+
if (playerInfo.error) {
|
|
13
|
+
return '绑定失败 (查询玩家信息失败)';
|
|
14
|
+
}
|
|
15
|
+
// 更新数据库
|
|
16
|
+
guildBind.saveOrUpdate(ctx.database, session.platform, session.userId, tmpId);
|
|
17
|
+
return `绑定成功 ( ${playerInfo.data.name} )`;
|
|
18
|
+
};
|
package/lib/command/tmpDlcMap.js
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
const { segment } = require('koishi')
|
|
2
|
-
const { resolve } = require('path')
|
|
3
|
-
const common = require('../util/common')
|
|
4
|
-
|
|
1
|
+
const { segment } = require('koishi');
|
|
2
|
+
const { resolve } = require('path');
|
|
3
|
+
const common = require('../util/common');
|
|
5
4
|
module.exports = async (ctx, session) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let page
|
|
11
|
-
try {
|
|
12
|
-
page = await ctx.puppeteer.page()
|
|
13
|
-
await page.setViewport({ width: 1000, height: 1000 })
|
|
14
|
-
await page.goto(`file:///${resolve(__dirname, '../resource/dlc.html')}`)
|
|
15
|
-
await page.waitForNetworkIdle()
|
|
16
|
-
await common.sleep(500)
|
|
17
|
-
const element = await page.$("#dlc-info-container");
|
|
18
|
-
return (
|
|
19
|
-
segment.image(await element.screenshot({
|
|
20
|
-
encoding: "binary"
|
|
21
|
-
}), "image/jpg")
|
|
22
|
-
)
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.info(e)
|
|
25
|
-
return '渲染异常,请重试'
|
|
26
|
-
} finally {
|
|
27
|
-
if (page) {
|
|
28
|
-
await page.close()
|
|
5
|
+
if (!ctx.puppeteer) {
|
|
6
|
+
return '未启用 Puppeteer 功能';
|
|
29
7
|
}
|
|
30
|
-
|
|
31
|
-
|
|
8
|
+
let page;
|
|
9
|
+
try {
|
|
10
|
+
page = await ctx.puppeteer.page();
|
|
11
|
+
await page.setViewport({ width: 1000, height: 1000 });
|
|
12
|
+
await page.goto(`file:///${resolve(__dirname, '../resource/dlc.html')}`);
|
|
13
|
+
await page.waitForNetworkIdle();
|
|
14
|
+
await common.sleep(500);
|
|
15
|
+
const element = await page.$("#dlc-info-container");
|
|
16
|
+
return (segment.image(await element.screenshot({
|
|
17
|
+
encoding: "binary"
|
|
18
|
+
}), "image/jpg"));
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
console.info(e);
|
|
22
|
+
return '渲染异常,请重试';
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
if (page) {
|
|
26
|
+
await page.close();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|