koishi-plugin-ets2-tools-tmp 3.1.4 → 3.1.6
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 +28 -2
- package/lib/command/tmpServer/tmpServer.js +3 -3
- package/lib/command/tmpServer/tmpServerImg.js +3 -3
- package/lib/command/tmpServer/tmpServerText.js +6 -3
- package/lib/resource/server-list.html +9 -1
- package/lib/resource/traffic.html +1 -1
- package/package.json +1 -1
package/lib/api/evmOpenApi.js
CHANGED
|
@@ -17,16 +17,42 @@ module.exports = {
|
|
|
17
17
|
/**
|
|
18
18
|
* 查询服务器列表
|
|
19
19
|
*/
|
|
20
|
-
async serverList(http) {
|
|
20
|
+
async serverList(http, game) {
|
|
21
21
|
let result = null
|
|
22
22
|
try {
|
|
23
|
-
result =
|
|
23
|
+
result = game === 'ATS'
|
|
24
|
+
? await http.get('https://api.114512.xyz/truckersmp/servers')
|
|
25
|
+
: await requestWithFallback(http, '/server/list')
|
|
24
26
|
} catch {
|
|
25
27
|
return {
|
|
26
28
|
error: true
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
if (game === 'ATS') {
|
|
33
|
+
const servers = result?.response
|
|
34
|
+
const isError = result?.error === true || !Array.isArray(servers)
|
|
35
|
+
return {
|
|
36
|
+
error: isError,
|
|
37
|
+
...(isError ? {} : {
|
|
38
|
+
data: servers
|
|
39
|
+
.filter(server => server.game === 'ATS')
|
|
40
|
+
.map(server => ({
|
|
41
|
+
serverName: server.name,
|
|
42
|
+
isOnline: server.online ? 1 : 0,
|
|
43
|
+
playerCount: server.players,
|
|
44
|
+
maxPlayer: server.maxplayers,
|
|
45
|
+
queueCount: server.queue || 0,
|
|
46
|
+
afkEnable: server.afkenabled ? 1 : 0,
|
|
47
|
+
collisionsEnable: server.collisions ? 1 : 0,
|
|
48
|
+
policeCarEnable: server.policecarsforplayers ? 1 : 0,
|
|
49
|
+
speedLimiterEnable: server.speedlimiter > 0 ? 1 : 0,
|
|
50
|
+
playerHistory: []
|
|
51
|
+
}))
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
30
56
|
// 拼接返回数据
|
|
31
57
|
let data = {
|
|
32
58
|
error: result.code !== 200
|
|
@@ -3,12 +3,12 @@ const tmpServerImg = require("./tmpServerImg");
|
|
|
3
3
|
/**
|
|
4
4
|
* 查询服务器列表
|
|
5
5
|
*/
|
|
6
|
-
module.exports = async (ctx, cfg) => {
|
|
6
|
+
module.exports = async (ctx, cfg, game) => {
|
|
7
7
|
switch (cfg.tmpServer?.type) {
|
|
8
8
|
case 1:
|
|
9
|
-
return await tmpServerText(ctx);
|
|
9
|
+
return await tmpServerText(ctx, game);
|
|
10
10
|
case 2:
|
|
11
|
-
return await tmpServerImg(ctx);
|
|
11
|
+
return await tmpServerImg(ctx, game);
|
|
12
12
|
default:
|
|
13
13
|
return '指令配置错误';
|
|
14
14
|
}
|
|
@@ -2,12 +2,12 @@ const evmOpenApi = require('../../api/evmOpenApi');
|
|
|
2
2
|
const { resolve } = require("path");
|
|
3
3
|
const common = require("../../util/common");
|
|
4
4
|
const { segment } = require("koishi");
|
|
5
|
-
module.exports = async (ctx) => {
|
|
5
|
+
module.exports = async (ctx, game) => {
|
|
6
6
|
if (!ctx.puppeteer) {
|
|
7
7
|
return '未启用 puppeteer 服务';
|
|
8
8
|
}
|
|
9
9
|
// 查询服务器信息
|
|
10
|
-
let serverData = await evmOpenApi.serverList(ctx.http);
|
|
10
|
+
let serverData = await evmOpenApi.serverList(ctx.http, game);
|
|
11
11
|
if (serverData.error) {
|
|
12
12
|
return '查询服务器失败,请稍后重试';
|
|
13
13
|
}
|
|
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
|
|
|
16
16
|
page = await ctx.puppeteer.page();
|
|
17
17
|
await page.setViewport({ width: 380, height: 1000, deviceScaleFactor: 1.5 });
|
|
18
18
|
await page.goto(`file:///${resolve(__dirname, '../../resource/server-list.html')}`);
|
|
19
|
-
await page.evaluate(`setData(${JSON.stringify(serverData)})`);
|
|
19
|
+
await page.evaluate(`setData(${JSON.stringify({ ...serverData, game })})`);
|
|
20
20
|
await common.sleep(100);
|
|
21
21
|
await page.waitForNetworkIdle();
|
|
22
22
|
const element = await page.$("#container");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const evmOpenApi = require('../../api/evmOpenApi');
|
|
2
|
-
module.exports = async (ctx) => {
|
|
2
|
+
module.exports = async (ctx, game) => {
|
|
3
3
|
// 查询服务器信息
|
|
4
|
-
let serverData = await evmOpenApi.serverList(ctx.http);
|
|
4
|
+
let serverData = await evmOpenApi.serverList(ctx.http, game);
|
|
5
5
|
if (serverData.error) {
|
|
6
6
|
return '查询服务器失败,请稍后重试';
|
|
7
7
|
}
|
|
@@ -14,7 +14,7 @@ module.exports = async (ctx) => {
|
|
|
14
14
|
}
|
|
15
15
|
message += '服务器: ' + (server.isOnline === 1 ? '🟢' : '⚫') + server.serverName;
|
|
16
16
|
message += `\n玩家人数: ${server.playerCount}/${server.maxPlayer}`;
|
|
17
|
-
if (server.
|
|
17
|
+
if (server.queueCount > 0) {
|
|
18
18
|
message += ` (队列: ${server.queueCount})`;
|
|
19
19
|
}
|
|
20
20
|
// 服务器特性
|
|
@@ -25,6 +25,9 @@ module.exports = async (ctx) => {
|
|
|
25
25
|
if (server.collisionsEnable === 1) {
|
|
26
26
|
characteristicList.push('💥碰撞');
|
|
27
27
|
}
|
|
28
|
+
if (server.speedLimiterEnable === 1) {
|
|
29
|
+
characteristicList.push('🐢限速');
|
|
30
|
+
}
|
|
28
31
|
if (characteristicList && characteristicList.length > 0) {
|
|
29
32
|
message += '\n服务器特性: ' + characteristicList.join(' ');
|
|
30
33
|
}
|
|
@@ -82,6 +82,13 @@
|
|
|
82
82
|
text-shadow: 0 0 10px rgba(0, 200, 255, 0.4);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
.header .title span.game-title {
|
|
86
|
+
margin-left: 4px;
|
|
87
|
+
color: #e0f0ff;
|
|
88
|
+
text-shadow: none;
|
|
89
|
+
letter-spacing: 1px;
|
|
90
|
+
}
|
|
91
|
+
|
|
85
92
|
.header-stats {
|
|
86
93
|
margin-left: auto;
|
|
87
94
|
display: flex;
|
|
@@ -307,7 +314,7 @@
|
|
|
307
314
|
|
|
308
315
|
<div class="header">
|
|
309
316
|
<span class="header-icon">📡</span>
|
|
310
|
-
<div class="title">TRUCKERS<span>MP</span>
|
|
317
|
+
<div class="title">TRUCKERS<span>MP</span> <span class="game-title" id="game-title">服务器</span></div>
|
|
311
318
|
<div class="header-stats">
|
|
312
319
|
<div class="header-stat">
|
|
313
320
|
<div class="header-stat-value" id="total-online">-</div>
|
|
@@ -436,6 +443,7 @@ function setData(apiData) {
|
|
|
436
443
|
const servers = apiData.data;
|
|
437
444
|
const listEl = document.getElementById('server-list');
|
|
438
445
|
listEl.innerHTML = '';
|
|
446
|
+
document.getElementById('game-title').textContent = apiData.game === 'ATS' ? '美卡服务器' : '欧卡服务器';
|
|
439
447
|
|
|
440
448
|
// Total online count
|
|
441
449
|
const totalOnline = servers.reduce((sum, s) => sum + (s.playerCount || 0), 0);
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
}
|
|
257
257
|
},
|
|
258
258
|
promods: {
|
|
259
|
-
tileUrl: 'https://
|
|
259
|
+
tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/promods/05102019/{z}/{x}/{y}.png',
|
|
260
260
|
multipliers: { x: 51953, y: 76024 },
|
|
261
261
|
breakpoints: { uk: { x: -31056.8, y: -5832.867 } },
|
|
262
262
|
bounds: { y: 131072, x: 131072 },
|