koishi-plugin-tmp-bot 1.14.1 → 1.14.3
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,50 @@ 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
|
+
}
|
|
47
|
+
return data
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 查询玩家信息
|
|
51
|
+
*/
|
|
52
|
+
async playerInfo (http, tmpId) {
|
|
53
|
+
let result = null
|
|
54
|
+
try {
|
|
55
|
+
result = await http.get(`${BASE_API}/player/info?tmpId=${tmpId}`)
|
|
56
|
+
} catch {
|
|
57
|
+
return {
|
|
58
|
+
error: true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 拼接返回数据
|
|
63
|
+
let data = {
|
|
64
|
+
error: result.code !== 200
|
|
65
|
+
}
|
|
66
|
+
if (!data.error) {
|
|
67
|
+
data.data = result.data
|
|
68
|
+
}
|
|
25
69
|
return data
|
|
26
70
|
}
|
|
27
71
|
}
|
|
@@ -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/tmpQuery.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const dayjs = require('dayjs')
|
|
2
2
|
const guildBind = require('../database/guildBind')
|
|
3
|
-
const truckersMpApi = require('../api/truckersMpApi')
|
|
4
3
|
const truckyAppApi = require('../api/truckyAppApi')
|
|
4
|
+
const evmOpenApi = require('../api/evmOpenApi')
|
|
5
5
|
const baiduTranslate = require('../util/baiduTranslate')
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -34,7 +34,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// 查询玩家信息
|
|
37
|
-
let playerInfo = await
|
|
37
|
+
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId)
|
|
38
38
|
if (playerInfo.error) {
|
|
39
39
|
return '查询玩家信息失败,请重试'
|
|
40
40
|
}
|
|
@@ -47,44 +47,31 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
47
47
|
if (cfg.queryShowAvatarEnable) {
|
|
48
48
|
message += `<img src="${playerInfo.data.avatar}"/>\n`
|
|
49
49
|
}
|
|
50
|
-
message += '🆔TMP编号: ' + playerInfo.data.
|
|
50
|
+
message += '🆔TMP编号: ' + playerInfo.data.tmpId
|
|
51
51
|
message += '\n😀玩家名称: ' + playerInfo.data.name
|
|
52
|
-
message += '\n🎮SteamID: ' + playerInfo.data.
|
|
53
|
-
let registerDate = dayjs(playerInfo.data.
|
|
52
|
+
message += '\n🎮SteamID: ' + playerInfo.data.steamId
|
|
53
|
+
let registerDate = dayjs(playerInfo.data.registerTime)
|
|
54
54
|
message += '\n📑注册日期: ' + registerDate.format('YYYY年MM月DD日') + ` (${dayjs().diff(registerDate, 'day')}天)`
|
|
55
55
|
message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName)
|
|
56
|
-
if (playerInfo.data.
|
|
57
|
-
message += '\n🚚所属车队: ' + playerInfo.data.
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
let vtcMemberResult = await truckersMpApi.vtcMember(ctx.http, playerInfo.data.vtc.id, playerInfo.data.vtc.memberID)
|
|
61
|
-
console.log(vtcMemberResult)
|
|
62
|
-
if (!vtcMemberResult.error) {
|
|
63
|
-
message += '\n🚚车队角色: ' + vtcMemberResult.data.role
|
|
64
|
-
}
|
|
65
|
-
} catch (e) {}
|
|
56
|
+
if (playerInfo.data.isJoinVtc) {
|
|
57
|
+
message += '\n🚚所属车队: ' + playerInfo.data.vtcName
|
|
58
|
+
message += '\n🚚车队角色: ' + playerInfo.data.vtcRole
|
|
66
59
|
}
|
|
67
|
-
message += '\n🚫是否封禁: ' + (playerInfo.data.
|
|
68
|
-
if (playerInfo.data.
|
|
60
|
+
message += '\n🚫是否封禁: ' + (playerInfo.data.isBan ? '是' : '否')
|
|
61
|
+
if (playerInfo.data.isBan) {
|
|
69
62
|
message += '\n🚫封禁截止: '
|
|
70
|
-
if (
|
|
63
|
+
if (playerInfo.data.banHide) {
|
|
71
64
|
message += '隐藏'
|
|
72
65
|
} else {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let ban = banData.data[0]
|
|
76
|
-
if (!ban.expiration) {
|
|
77
|
-
message += '永久'
|
|
78
|
-
} else {
|
|
79
|
-
message += dayjs(ban.expiration + 'Z').format('YYYY年MM月DD日 HH:mm')
|
|
80
|
-
}
|
|
81
|
-
message += "\n🚫封禁原因: " + await baiduTranslate(ctx, cfg, ban.reason, false)
|
|
66
|
+
if (!playerInfo.data.banUntil) {
|
|
67
|
+
message += '永久'
|
|
82
68
|
} else {
|
|
83
|
-
message += '
|
|
69
|
+
message += dayjs(playerInfo.data.banUntil).format('YYYY年MM月DD日 HH:mm')
|
|
84
70
|
}
|
|
71
|
+
message += "\n🚫封禁原因: " + (playerInfo.data.banReasonZh || playerInfo.data.banReason)
|
|
85
72
|
}
|
|
86
73
|
}
|
|
87
|
-
message += '\n🚫封禁次数: ' + playerInfo.data.
|
|
74
|
+
message += '\n🚫封禁次数: ' + playerInfo.data.banCount || 0
|
|
88
75
|
if (playerMapInfo && !playerMapInfo.error) {
|
|
89
76
|
message += '\n📶在线状态: ' + (playerMapInfo.data.online ? `在线🟢 (${playerMapInfo.data.serverDetails.name})` : '离线⚫')
|
|
90
77
|
if (playerMapInfo.data.online) {
|
|
@@ -94,11 +81,10 @@ module.exports = async (ctx, cfg, session, tmpId) => {
|
|
|
94
81
|
message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName)
|
|
95
82
|
}
|
|
96
83
|
}
|
|
97
|
-
|
|
98
|
-
if (patreon && patreon.active) {
|
|
84
|
+
if (playerInfo.data.isSponsor) {
|
|
99
85
|
message += '\n🎁赞助用户'
|
|
100
|
-
if (!
|
|
101
|
-
message += ` (\$${Math.floor(
|
|
86
|
+
if (!playerInfo.data.sponsorHide) {
|
|
87
|
+
message += ` (\$${Math.floor(playerInfo.data.sponsorAmount / 100)})`
|
|
102
88
|
}
|
|
103
89
|
}
|
|
104
90
|
return message
|
|
@@ -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
|
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Title</title>
|
|
6
|
+
<style>
|
|
7
|
+
.border {
|
|
8
|
+
border: 1px solid red;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.form-box {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
}
|
|
15
|
+
.form-box .form-item {
|
|
16
|
+
width: 50%;
|
|
17
|
+
}
|
|
18
|
+
.form-box .form-item.full {
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#container {
|
|
23
|
+
width: 400px;
|
|
24
|
+
background: linear-gradient(135deg, #1f2f54, #0f2c2a);
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.header {
|
|
29
|
+
height: 100px;
|
|
30
|
+
background-color: rgba(0, 0, 0, .1);
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
padding: 0 26px;
|
|
34
|
+
box-shadow: 0 0 16px rgba(0, 0, 0, .4);
|
|
35
|
+
}
|
|
36
|
+
.header .avatar {
|
|
37
|
+
width: 64px;
|
|
38
|
+
height: 64px;
|
|
39
|
+
}
|
|
40
|
+
.header .info {
|
|
41
|
+
flex: 1;
|
|
42
|
+
padding-left: 16px;
|
|
43
|
+
}
|
|
44
|
+
.header .info .name {
|
|
45
|
+
color: #b0c7ff;
|
|
46
|
+
font-size: 18px;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
}
|
|
49
|
+
.header .info .tmp-id {
|
|
50
|
+
color: #aaaaaa;
|
|
51
|
+
font-size: 14px;
|
|
52
|
+
margin-top: 4px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.details-container {
|
|
56
|
+
padding: 12px 26px;
|
|
57
|
+
}
|
|
58
|
+
.details-container .form-item {
|
|
59
|
+
margin-top: 12px;
|
|
60
|
+
}
|
|
61
|
+
.details-container .form-item:nth-child(1) {
|
|
62
|
+
margin-top: 0;
|
|
63
|
+
}
|
|
64
|
+
.details-container .form-item .label {
|
|
65
|
+
color: #dddddd;
|
|
66
|
+
}
|
|
67
|
+
.details-container .form-item .value {
|
|
68
|
+
color: #ffffff;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ban-container {
|
|
72
|
+
margin: 16px 26px;
|
|
73
|
+
background-color: rgba(227, 92, 92, 0.3);
|
|
74
|
+
}
|
|
75
|
+
.ban-header {
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 30px;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
padding: 0 12px;
|
|
80
|
+
color: #ffffff;
|
|
81
|
+
font-size: 16px;
|
|
82
|
+
line-height: 30px;
|
|
83
|
+
background-color: rgba(227, 92, 92, 0.6);
|
|
84
|
+
}
|
|
85
|
+
.ban-body {
|
|
86
|
+
padding: 12px 16px;
|
|
87
|
+
}
|
|
88
|
+
.ban-body .ban-hidden {
|
|
89
|
+
color: #cccccc;
|
|
90
|
+
font-size: 14px;
|
|
91
|
+
font-style: italic;
|
|
92
|
+
text-align: center;
|
|
93
|
+
}
|
|
94
|
+
.ban-body .form-item {
|
|
95
|
+
margin-top: 8px;
|
|
96
|
+
}
|
|
97
|
+
.ban-body .form-item:nth-child(1),
|
|
98
|
+
.ban-body .form-item:nth-child(2){
|
|
99
|
+
margin-top: 0;
|
|
100
|
+
}
|
|
101
|
+
.ban-body .form-item .label {
|
|
102
|
+
color: #cccccc;
|
|
103
|
+
font-size: 12px;
|
|
104
|
+
}
|
|
105
|
+
.ban-body .form-item .value {
|
|
106
|
+
color: #eeeeee;
|
|
107
|
+
font-size: 14px;
|
|
108
|
+
word-wrap: break-word;
|
|
109
|
+
word-break: break-all;
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
112
|
+
</head>
|
|
113
|
+
<body>
|
|
114
|
+
<!--
|
|
115
|
+
🆔TMP编号: 5672599
|
|
116
|
+
😀玩家名称: MakeKazakh
|
|
117
|
+
🎮SteamID: 76561199225329400
|
|
118
|
+
📑注册日期: 2024年11月03日 (186天)
|
|
119
|
+
💼所属分组: 玩家
|
|
120
|
+
🚚所属车队: Kazakhstan-Taraz Truckers
|
|
121
|
+
🚚车队角色: Owner
|
|
122
|
+
🚫是否封禁: 否
|
|
123
|
+
🚫封禁次数: 0
|
|
124
|
+
📶在线状态: 在线🟢 (Simulation 1)
|
|
125
|
+
🌍线上位置: 法国 - 加莱-杜伊斯堡 -->
|
|
126
|
+
<div id="container">
|
|
127
|
+
<div class="header">
|
|
128
|
+
<img class="avatar" src="https://static.truckersmp.com/avatarsN/4763167.1710207515.jpg" alt="avatar"/>
|
|
129
|
+
<div class="info">
|
|
130
|
+
<div class="name">*ACC* 014 kuroneko</div>
|
|
131
|
+
<div class="tmp-id">TMP#4763167</div>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="details-container">
|
|
135
|
+
<div class="form-box">
|
|
136
|
+
<div class="form-item">
|
|
137
|
+
<div class="label">🎮SteamID</div>
|
|
138
|
+
<div class="value">76561198354836885</div>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="form-item full">
|
|
141
|
+
<div class="label">📑注册日期</div>
|
|
142
|
+
<div class="value">2024年12月18日 (141天)</div>
|
|
143
|
+
</div>
|
|
144
|
+
<div class="form-item full">
|
|
145
|
+
<div class="label">💼所属分组</div>
|
|
146
|
+
<div class="value">玩家</div>
|
|
147
|
+
</div>
|
|
148
|
+
<div class="form-item full">
|
|
149
|
+
<div class="label">🚚所属车队</div>
|
|
150
|
+
<div class="value">Kazakhstan-Taraz Truckers</div>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="form-item full">
|
|
153
|
+
<div class="label">🚚车队角色</div>
|
|
154
|
+
<div class="value">Owner</div>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="ban-container">
|
|
159
|
+
<div class="ban-header">封禁中</div>
|
|
160
|
+
<div class="ban-body">
|
|
161
|
+
<div class="ban-hidden">玩家隐藏</div>
|
|
162
|
+
<!-- <div class="form-box">-->
|
|
163
|
+
<!-- <div class="form-item">-->
|
|
164
|
+
<!-- <div class="label">截止时间</div>-->
|
|
165
|
+
<!-- <div class="value">2020-09-09 09:09:09</div>-->
|
|
166
|
+
<!-- </div>-->
|
|
167
|
+
<!-- <div class="form-item">-->
|
|
168
|
+
<!-- <div class="label">封禁次数</div>-->
|
|
169
|
+
<!-- <div class="value">5次</div>-->
|
|
170
|
+
<!-- </div>-->
|
|
171
|
+
<!-- <div class="form-item full">-->
|
|
172
|
+
<!-- <div class="label">原因</div>-->
|
|
173
|
+
<!-- <div class="value">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>-->
|
|
174
|
+
<!-- </div>-->
|
|
175
|
+
<!-- </div>-->
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</body>
|
|
180
|
+
</html>
|
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.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",
|