koishi-plugin-ets2-tools-tmp 3.2.0 → 3.3.0
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 +26 -4
- package/lib/api/truckersMpApi.js +1 -1
- package/lib/api/truckersMpMapApi.js +1 -1
- package/lib/api/truckyAppApi.js +1 -1
- package/lib/command/tmpQuery/tmpQueryImg.js +1 -1
- package/lib/command/tmpQuery/tmpQueryText.js +1 -1
- package/lib/command/tmpVtcOnline/tmpVtcOnlineImg.js +3 -2
- package/lib/command/tmpVtcOnline/tmpVtcOnlineText.js +3 -2
- package/package.json +1 -1
package/lib/api/evmOpenApi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const BASE_APIS = ['https://evmapi.
|
|
1
|
+
const BASE_APIS = ['https://evmapi.cxnnn.cn']
|
|
2
2
|
|
|
3
3
|
async function requestWithFallback(http, path) {
|
|
4
4
|
let lastError = null
|
|
@@ -21,8 +21,8 @@ module.exports = {
|
|
|
21
21
|
let result = null
|
|
22
22
|
try {
|
|
23
23
|
result = game === 'ATS'
|
|
24
|
-
? await http.get(
|
|
25
|
-
: await requestWithFallback(http,
|
|
24
|
+
? await http.get(`${BASE_APIS[0]}/proxy/truckersmp/servers`)
|
|
25
|
+
: await requestWithFallback(http, `/server/list`)
|
|
26
26
|
} catch {
|
|
27
27
|
return {
|
|
28
28
|
error: true
|
|
@@ -195,5 +195,27 @@ module.exports = {
|
|
|
195
195
|
data.data = result.data
|
|
196
196
|
}
|
|
197
197
|
return data
|
|
198
|
-
}
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* VTC在线成员
|
|
201
|
+
*/
|
|
202
|
+
async vtcOnlineList(http, vtcId) {
|
|
203
|
+
let result = null
|
|
204
|
+
try {
|
|
205
|
+
result = await requestWithFallback(http, `/vtc/memberOnline?vtcId=${vtcId}`)
|
|
206
|
+
} catch (e) {
|
|
207
|
+
return {
|
|
208
|
+
error: true
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 拼接返回数据
|
|
213
|
+
let data = {
|
|
214
|
+
error: result.code !== 200
|
|
215
|
+
}
|
|
216
|
+
if (!data.error) {
|
|
217
|
+
data.data = result.data
|
|
218
|
+
}
|
|
219
|
+
return data
|
|
220
|
+
},
|
|
199
221
|
}
|
package/lib/api/truckersMpApi.js
CHANGED
package/lib/api/truckyAppApi.js
CHANGED
|
@@ -165,7 +165,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
165
165
|
const steamApiKey = cfg.steamApi?.key;
|
|
166
166
|
if (steamApiKey) {
|
|
167
167
|
const steamId = playerInfo.data.steamId;
|
|
168
|
-
const url = `https://evmapi.
|
|
168
|
+
const url = `https://evmapi.cxnnn.cn/proxy/steam/IPlayerService/GetOwnedGames/v1?key=${steamApiKey}&steamid=${steamId}&appids_filter[0]=227300&appids_filter[1]=270880&include_played_free_games=1`;
|
|
169
169
|
const response = await ctx.http.get(url);
|
|
170
170
|
if (response.response && response.response.game_count > 0) {
|
|
171
171
|
for (const game of response.response.games) {
|
|
@@ -189,7 +189,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
189
189
|
if (!steamApiKey) {
|
|
190
190
|
return { ets2: null, ats: null };
|
|
191
191
|
}
|
|
192
|
-
const url = `https://
|
|
192
|
+
const url = `https://evmapi.cxnnn.cn/proxy/steam/IPlayerService/GetOwnedGames/v1?key=${steamApiKey}&steamid=${steamId}&appids_filter[0]=227300&appids_filter[1]=270880&include_played_free_games=1`;
|
|
193
193
|
const response = await ctx.http.get(url);
|
|
194
194
|
const result = { ets2: null, ats: null };
|
|
195
195
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { segment } = require('koishi');
|
|
2
2
|
const { resolve } = require('path');
|
|
3
3
|
const common = require('../../util/common');
|
|
4
|
+
const evmOpenApi = require('../../api/evmOpenApi');
|
|
4
5
|
|
|
5
6
|
module.exports = async (ctx, cfg) => {
|
|
6
7
|
const vtcId = cfg.tmpActivityService?.api?.vtcId;
|
|
@@ -10,12 +11,12 @@ module.exports = async (ctx, cfg) => {
|
|
|
10
11
|
|
|
11
12
|
let result;
|
|
12
13
|
try {
|
|
13
|
-
result = await ctx.http
|
|
14
|
+
result = await evmOpenApi.vtcOnlineList(ctx.http, vtcId);
|
|
14
15
|
} catch {
|
|
15
16
|
return '查询车队在线成员失败,请稍后重试';
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
if (
|
|
19
|
+
if (result.error || !Array.isArray(result.data)) {
|
|
19
20
|
return '查询车队在线成员失败,请稍后重试';
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const evmOpenApi = require('../../api/evmOpenApi');
|
|
1
2
|
module.exports = async (ctx, cfg) => {
|
|
2
3
|
const vtcId = cfg.tmpActivityService?.api?.vtcId;
|
|
3
4
|
if (!vtcId) {
|
|
@@ -6,12 +7,12 @@ module.exports = async (ctx, cfg) => {
|
|
|
6
7
|
|
|
7
8
|
let result;
|
|
8
9
|
try {
|
|
9
|
-
result = await ctx.http
|
|
10
|
+
result = await evmOpenApi.vtcOnlineList(ctx.http, vtcId);
|
|
10
11
|
} catch {
|
|
11
12
|
return '查询车队在线成员失败,请稍后重试';
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
if (
|
|
15
|
+
if (result.error || !Array.isArray(result.data)) {
|
|
15
16
|
return '查询车队在线成员失败,请稍后重试';
|
|
16
17
|
}
|
|
17
18
|
|