koishi-plugin-tmp-bot 1.14.0 → 1.14.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.
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -3,7 +3,7 @@ const { resolve } = require('path')
|
|
|
3
3
|
const guildBind = require('../database/guildBind')
|
|
4
4
|
const truckyAppApi = require('../api/truckyAppApi')
|
|
5
5
|
const truckersMpApi = require('../api/truckersMpApi')
|
|
6
|
-
const
|
|
6
|
+
const evmOpenApi = require('../api/evmOpenApi')
|
|
7
7
|
const baiduTranslate = require('../util/baiduTranslate')
|
|
8
8
|
const common = require('../util/common')
|
|
9
9
|
|
|
@@ -41,7 +41,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// 查询周边玩家,并处理数据
|
|
44
|
-
let areaPlayersData = await
|
|
44
|
+
let areaPlayersData = await evmOpenApi.mapPlayerList(ctx.http, playerMapInfo.data.server,
|
|
45
45
|
playerMapInfo.data.x - 4000,
|
|
46
46
|
playerMapInfo.data.y + 2500,
|
|
47
47
|
playerMapInfo.data.x + 4000,
|
|
@@ -50,16 +50,16 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
50
50
|
if (!areaPlayersData.error) {
|
|
51
51
|
areaPlayerList = areaPlayersData.data
|
|
52
52
|
let index = areaPlayerList.findIndex((player) => {
|
|
53
|
-
return player.
|
|
53
|
+
return player.tmpId.toString() === tmpId.toString()
|
|
54
54
|
})
|
|
55
55
|
if (index !== -1) {
|
|
56
56
|
areaPlayerList.splice(index, 1)
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
areaPlayerList.push({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
axisX: playerMapInfo.data.x,
|
|
61
|
+
axisY: playerMapInfo.data.y,
|
|
62
|
+
tmpId
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
// promods服ID集合
|
package/lib/command/tmpServer.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
const truckersMpApi = require('../api/truckersMpApi')
|
|
2
|
+
const evmOpenApi = require('../api/evmOpenApi')
|
|
2
3
|
|
|
3
|
-
module.exports = async (ctx
|
|
4
|
+
module.exports = async (ctx) => {
|
|
4
5
|
// 查询服务器信息
|
|
5
|
-
let serverData = await
|
|
6
|
+
let serverData = await evmOpenApi.serverList(ctx.http)
|
|
6
7
|
if (serverData.error) {
|
|
7
8
|
return '查询服务器失败,请稍后重试'
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
// 过滤服务器
|
|
11
|
-
let etsServerList = serverData.data.filter(server => server.game === game)
|
|
12
|
-
|
|
13
11
|
// 构建消息
|
|
14
12
|
let message = ''
|
|
15
|
-
for (let server of
|
|
13
|
+
for (let server of serverData.data) {
|
|
16
14
|
// 如果前面有内容,换行
|
|
17
15
|
if (message) {
|
|
18
16
|
message += '\n\n'
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
message += '服务器: ' + ( server.
|
|
22
|
-
message += `\n玩家人数: ${server.
|
|
19
|
+
message += '服务器: ' + ( server.isOnline === 1 ? '🟢' : '⚫' ) + server.serverName
|
|
20
|
+
message += `\n玩家人数: ${server.playerCount}/${server.maxPlayer}`
|
|
23
21
|
if (server.queue) {
|
|
24
|
-
message += ` (队列: ${server.
|
|
22
|
+
message += ` (队列: ${server.queueCount})`
|
|
25
23
|
}
|
|
26
24
|
// 服务器特性
|
|
27
25
|
let characteristicList = []
|
|
28
|
-
if (!server.
|
|
26
|
+
if (!(server.afkEnable === 1)) {
|
|
29
27
|
characteristicList.push('⏱挂机')
|
|
30
28
|
}
|
|
31
|
-
if (server.
|
|
29
|
+
if (server.collisionsEnable === 1) {
|
|
32
30
|
characteristicList.push('💥碰撞')
|
|
33
31
|
}
|
|
34
32
|
if (characteristicList && characteristicList.length > 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const truckyAppApi = require('../../api/truckyAppApi')
|
|
2
|
-
const
|
|
2
|
+
const evmOpenApi = require('../../api/evmOpenApi')
|
|
3
3
|
const baiduTranslate = require('../../util/baiduTranslate')
|
|
4
4
|
const {resolve} = require("path");
|
|
5
5
|
const common = require("../../util/common");
|
|
@@ -87,13 +87,13 @@ module.exports = async (ctx, cfg, serverName) => {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// 查询地图玩家数据
|
|
90
|
-
let mapData = await
|
|
90
|
+
let mapData = await evmOpenApi.mapPlayerList(ctx.http, serverInfo.serverId, serverInfo.bounds[0][0], serverInfo.bounds[0][1], serverInfo.bounds[1][0], serverInfo.bounds[1][1])
|
|
91
91
|
|
|
92
92
|
// 构建路况数据
|
|
93
93
|
let data = {
|
|
94
94
|
mapType: serverInfo.mapType,
|
|
95
95
|
trafficList: [],
|
|
96
|
-
playerCoordinateList: mapData.error && mapData.data ? [] : mapData.data.map(item => [item.
|
|
96
|
+
playerCoordinateList: mapData.error && mapData.data ? [] : mapData.data.map(item => [item.axisX, item.axisY])
|
|
97
97
|
}
|
|
98
98
|
for (const traffic of trafficData.data) {
|
|
99
99
|
data.trafficList.push({
|
package/lib/index.js
CHANGED
|
@@ -35,8 +35,7 @@ function apply(ctx, cfg) {
|
|
|
35
35
|
model(ctx);
|
|
36
36
|
// 注册指令
|
|
37
37
|
ctx.command('tmpquery <tmpId>').action(async ({ session }, tmpId) => await tmpQuery(ctx, cfg, session, tmpId));
|
|
38
|
-
ctx.command('
|
|
39
|
-
ctx.command('tmpserverets').action(async () => await tmpServer(ctx, cfg, 'ETS2'));
|
|
38
|
+
ctx.command('tmpserverets').action(async () => await tmpServer(ctx));
|
|
40
39
|
ctx.command('tmpbind <tmpId>').action(async ({ session }, tmpId) => await tmpBind(ctx, cfg, session, tmpId));
|
|
41
40
|
ctx.command('tmptraffic <serverName>').action(async ({ session }, serverName) => await tmpTraffic(ctx, cfg, serverName));
|
|
42
41
|
ctx.command('tmpposition <tmpId>').action(async ({ session }, tmpId) => await tmpPosition(ctx, cfg, session, tmpId));
|
|
@@ -205,13 +205,13 @@
|
|
|
205
205
|
document.getElementsByClassName('real-name')[0].innerText = data.realName
|
|
206
206
|
|
|
207
207
|
for (let player of data.playerList) {
|
|
208
|
-
L.circleMarker(map.unproject(mapConfig[data.mapType].calculateMapCoordinate(player.
|
|
208
|
+
L.circleMarker(map.unproject(mapConfig[data.mapType].calculateMapCoordinate(player.axisX, player.axisY), 8), {
|
|
209
209
|
color: '#2f2f2f', // 标记点边框颜色
|
|
210
210
|
weight: 2, // 标记点边框大小
|
|
211
|
-
fillColor: data.currentPlayerId.toString() === player.
|
|
211
|
+
fillColor: data.currentPlayerId.toString() === player.tmpId.toString() ? '#1cb715' : '#158cfb', // 标记点填充颜色
|
|
212
212
|
fillOpacity: 1, // 标记点填充不透明度(0到1之间的值)
|
|
213
213
|
radius: 5, // 标记点半径(以像素为单位)
|
|
214
|
-
zIndex: data.currentPlayerId.toString() === player.
|
|
214
|
+
zIndex: data.currentPlayerId.toString() === player.tmpId.toString() ? 1000 : undefined
|
|
215
215
|
}).addTo(map);
|
|
216
216
|
}
|
|
217
217
|
|
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.14.
|
|
4
|
+
"version": "1.14.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",
|