koishi-plugin-tmp-bot 1.14.1 → 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.
package/lib/api/evmOpenApi.js
CHANGED
|
@@ -22,6 +22,28 @@ module.exports = {
|
|
|
22
22
|
data.data = result.data
|
|
23
23
|
}
|
|
24
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
|
+
}
|
|
25
47
|
return data
|
|
26
48
|
}
|
|
27
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集合
|
|
@@ -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({
|
|
@@ -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",
|