koishi-plugin-ets2-tools-tmp 3.0.2 → 3.0.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.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
const
|
|
1
|
+
const BASE_APIS = ['https://da.vtcm.link', 'https://evmapi.114512.xyz']
|
|
2
|
+
|
|
3
|
+
async function requestWithFallback(http, path) {
|
|
4
|
+
let lastError = null
|
|
5
|
+
for (const baseUrl of BASE_APIS) {
|
|
6
|
+
try {
|
|
7
|
+
const result = await http.get(`${baseUrl}${path}`)
|
|
8
|
+
return result
|
|
9
|
+
} catch (e) {
|
|
10
|
+
lastError = e
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
throw lastError
|
|
14
|
+
}
|
|
2
15
|
|
|
3
16
|
module.exports = {
|
|
4
17
|
/**
|
|
@@ -7,7 +20,7 @@ module.exports = {
|
|
|
7
20
|
async serverList(http) {
|
|
8
21
|
let result = null
|
|
9
22
|
try {
|
|
10
|
-
result = await http
|
|
23
|
+
result = await requestWithFallback(http, '/server/list')
|
|
11
24
|
} catch {
|
|
12
25
|
return {
|
|
13
26
|
error: true
|
|
@@ -30,7 +43,7 @@ module.exports = {
|
|
|
30
43
|
async mapPlayerList(http, serverId, ax, ay, bx, by) {
|
|
31
44
|
let result = null
|
|
32
45
|
try {
|
|
33
|
-
result = await http
|
|
46
|
+
result = await requestWithFallback(http, `/map/playerList?aAxisX=${ax}&aAxisY=${ay}&bAxisX=${bx}&bAxisY=${by}&serverId=${serverId}`)
|
|
34
47
|
} catch {
|
|
35
48
|
return {
|
|
36
49
|
error: true
|
|
@@ -52,7 +65,7 @@ module.exports = {
|
|
|
52
65
|
async playerInfo(http, tmpId) {
|
|
53
66
|
let result = null
|
|
54
67
|
try {
|
|
55
|
-
result = await http
|
|
68
|
+
result = await requestWithFallback(http, `/player/info?tmpId=${tmpId}`)
|
|
56
69
|
} catch {
|
|
57
70
|
return {
|
|
58
71
|
error: true
|
|
@@ -75,7 +88,7 @@ module.exports = {
|
|
|
75
88
|
async dlcList(http, type) {
|
|
76
89
|
let result = null
|
|
77
90
|
try {
|
|
78
|
-
result = await http
|
|
91
|
+
result = await requestWithFallback(http, `/dlc/list?type=${type}`)
|
|
79
92
|
} catch (e) {
|
|
80
93
|
return {
|
|
81
94
|
error: true
|
|
@@ -97,7 +110,7 @@ module.exports = {
|
|
|
97
110
|
async mileageRankingList(http, rankingType, tmpId) {
|
|
98
111
|
let result = null
|
|
99
112
|
try {
|
|
100
|
-
result = await http
|
|
113
|
+
result = await requestWithFallback(http, `/statistics/mileageRankingList?rankingType=${rankingType}&tmpId=${tmpId || ''}&rankingCount=10`)
|
|
101
114
|
} catch (e) {
|
|
102
115
|
return {
|
|
103
116
|
error: true
|
|
@@ -119,7 +132,7 @@ module.exports = {
|
|
|
119
132
|
async mapPlayerHistory(http, tmpId, serverId, startTime, endTime) {
|
|
120
133
|
let result = null
|
|
121
134
|
try {
|
|
122
|
-
result = await http
|
|
135
|
+
result = await requestWithFallback(http, `/map/playerHistory?tmpId=${tmpId || ''}&serverId=${serverId || ''}&startTime=${startTime || ''}&endTime=${endTime || ''}`)
|
|
123
136
|
} catch {
|
|
124
137
|
return {
|
|
125
138
|
error: true
|
|
@@ -135,4 +148,4 @@ module.exports = {
|
|
|
135
148
|
}
|
|
136
149
|
return data
|
|
137
150
|
}
|
|
138
|
-
}
|
|
151
|
+
}
|
|
@@ -98,7 +98,7 @@ module.exports = async (ctx, cfg, session, target, changeType, quantity, reason)
|
|
|
98
98
|
return changeResponse.msg || "积分修改失败";
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
return `积分修改成功!\n
|
|
101
|
+
return `积分修改成功!\n操作: ${changeType} ${quantityNum} 积分`;
|
|
102
102
|
|
|
103
103
|
} catch (error) {
|
|
104
104
|
ctx.logger.error(`[V1] 积分修改错误: ${error.message}`);
|