koishi-plugin-tmp-bot 1.14.2 → 1.14.4

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.
@@ -37,6 +37,28 @@ module.exports = {
37
37
  }
38
38
  }
39
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
+
40
62
  // 拼接返回数据
41
63
  let data = {
42
64
  error: result.code !== 200
@@ -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 truckersMpApi.player(ctx.http, tmpId)
37
+ let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId)
38
38
  if (playerInfo.error) {
39
39
  return '查询玩家信息失败,请重试'
40
40
  }
@@ -45,46 +45,33 @@ module.exports = async (ctx, cfg, session, tmpId) => {
45
45
  // 拼接消息模板
46
46
  let message = ''
47
47
  if (cfg.queryShowAvatarEnable) {
48
- message += `<img src="${playerInfo.data.avatar}"/>\n`
48
+ message += `<img src="${playerInfo.data.avatarUrl}"/>\n`
49
49
  }
50
- message += '🆔TMP编号: ' + playerInfo.data.id
50
+ message += '🆔TMP编号: ' + playerInfo.data.tmpId
51
51
  message += '\n😀玩家名称: ' + playerInfo.data.name
52
- message += '\n🎮SteamID: ' + playerInfo.data.steamID64
53
- let registerDate = dayjs(playerInfo.data.joinDate + 'Z')
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.vtc && playerInfo.data.vtc.inVTC) {
57
- message += '\n🚚所属车队: ' + playerInfo.data.vtc.name
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.banned ? '是' : '否')
68
- if (playerInfo.data.banned) {
60
+ message += '\n🚫是否封禁: ' + (playerInfo.data.isBan ? '是' : '否')
61
+ if (playerInfo.data.isBan) {
69
62
  message += '\n🚫封禁截止: '
70
- if (!playerInfo.data.displayBans) {
63
+ if (playerInfo.data.banHide) {
71
64
  message += '隐藏'
72
65
  } else {
73
- let banData = await truckersMpApi.bans(ctx.http, tmpId)
74
- if (!banData.error) {
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.bansCount || 0
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
- let patreon = playerInfo.data.patreon
98
- if (patreon && patreon.active) {
84
+ if (playerInfo.data.isSponsor) {
99
85
  message += '\n🎁赞助用户'
100
- if (!patreon.hidden) {
101
- message += ` (\$${Math.floor(patreon.currentPledge / 100)})`
86
+ if (!playerInfo.data.sponsorHide) {
87
+ message += ` (\$${Math.floor(playerInfo.data.sponsorAmount / 100)})`
102
88
  }
103
89
  }
104
90
  return message
@@ -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.2",
4
+ "version": "1.14.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "homepage": "https://github.com/79887143/koishi-plugin-tmp-bot",