koishi-plugin-ets2-tools-tmp 2.3.0 → 2.3.1
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 +138 -1
- package/lib/api/truckersMpApi.js +133 -1
- package/lib/api/truckersMpMapApi.js +25 -1
- package/lib/api/truckyAppApi.js +48 -1
- package/lib/command/ets-app/queryPoint.js +96 -1
- package/lib/command/ets-app/resetPassword.js +270 -1
- package/lib/command/tmpActivityService.js +603 -1
- package/lib/command/tmpBind.js +19 -1
- package/lib/command/tmpDlcMap.js +33 -1
- package/lib/command/tmpFootprint.js +109 -1
- package/lib/command/tmpMileageRanking.js +55 -1
- package/lib/command/tmpPosition.js +123 -1
- package/lib/command/tmpQuery/tmpQuery.js +12 -1
- package/lib/command/tmpQuery/tmpQueryImg.js +103 -1
- package/lib/command/tmpQuery/tmpQueryText.js +196 -1
- package/lib/command/tmpServer.js +41 -1
- package/lib/command/tmpTraffic/tmpTraffic.js +15 -1
- package/lib/command/tmpTraffic/tmpTrafficMap.js +163 -1
- package/lib/command/tmpTraffic/tmpTrafficText.js +60 -1
- package/lib/command/tmpVersion.js +14 -1
- package/lib/command/tmpVtc.js +29 -1
- package/lib/database/guildBind.js +41 -1
- package/lib/database/model.js +65 -1
- package/lib/database/translateCache.js +31 -1
- package/lib/index.js +331 -1
- package/lib/resource/dlc.html +1 -1
- package/lib/resource/footprint.html +1 -1
- package/lib/resource/package/ets-map.js +63 -1
- package/lib/resource/package/leaflet/heatmap.min.js +9 -1
- package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -1
- package/lib/resource/position.html +1 -1
- package/lib/resource/traffic.html +1 -1
- package/lib/util/baiduTranslate.js +24 -1
- package/lib/util/common.js +5 -1
- package/lib/util/constant.js +36 -1
- package/package.json +1 -1
package/lib/command/tmpBind.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
const guildBind = require('../database/guildBind');
|
|
2
|
+
const truckersMpApi = require("../api/truckersMpApi");
|
|
3
|
+
const evmOpenApi = require('../api/evmOpenApi');
|
|
4
|
+
/**
|
|
5
|
+
* 绑定 TMP ID
|
|
6
|
+
*/
|
|
7
|
+
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
8
|
+
if (!tmpId || isNaN(tmpId)) {
|
|
9
|
+
return `请输入正确的玩家编号`;
|
|
10
|
+
}
|
|
11
|
+
// 查询玩家信息
|
|
12
|
+
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
|
|
13
|
+
if (playerInfo.error) {
|
|
14
|
+
return '绑定失败 (查询玩家信息失败)';
|
|
15
|
+
}
|
|
16
|
+
// 更新数据库
|
|
17
|
+
guildBind.saveOrUpdate(ctx.database, session.platform, session.userId, playerInfo.data.tmpId);
|
|
18
|
+
return `绑定成功 ( ${playerInfo.data.name} )`;
|
|
19
|
+
};
|
package/lib/command/tmpDlcMap.js
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { segment } = require('koishi');
|
|
2
|
+
const { resolve } = require('path');
|
|
3
|
+
const common = require('../util/common');
|
|
4
|
+
const evmOpenApi = require('../api/evmOpenApi');
|
|
5
|
+
module.exports = async (ctx, session) => {
|
|
6
|
+
if (!ctx.puppeteer) {
|
|
7
|
+
return '未启用 Puppeteer 功能';
|
|
8
|
+
}
|
|
9
|
+
// 查询DLC数据
|
|
10
|
+
let dlcData = await evmOpenApi.dlcList(ctx.http, 1);
|
|
11
|
+
let page;
|
|
12
|
+
try {
|
|
13
|
+
page = await ctx.puppeteer.page();
|
|
14
|
+
await page.setViewport({ width: 1000, height: 1000 });
|
|
15
|
+
await page.goto(`file:///${resolve(__dirname, '../resource/dlc.html')}`);
|
|
16
|
+
await page.evaluate(`setData(${JSON.stringify(dlcData.data)})`);
|
|
17
|
+
await page.waitForNetworkIdle();
|
|
18
|
+
await common.sleep(500);
|
|
19
|
+
const element = await page.$("#dlc-info-container");
|
|
20
|
+
return (segment.image(await element.screenshot({
|
|
21
|
+
encoding: "binary"
|
|
22
|
+
}), "image/jpg"));
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
console.info(e);
|
|
26
|
+
return '渲染异常,请重试';
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
if (page) {
|
|
30
|
+
await page.close();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -1 +1,109 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { segment } = require('koishi')
|
|
2
|
+
const dayjs = require('dayjs')
|
|
3
|
+
const { resolve } = require('path')
|
|
4
|
+
const common = require('../util/common')
|
|
5
|
+
const { PromodsIds, ServerType } = require('../util/constant')
|
|
6
|
+
const evmOpenApi = require('../api/evmOpenApi')
|
|
7
|
+
const guildBind = require('../database/guildBind')
|
|
8
|
+
|
|
9
|
+
module.exports = async (ctx, session, serverType, tmpId) => {
|
|
10
|
+
if (!ctx.puppeteer) {
|
|
11
|
+
return '未启用 puppeteer 服务'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (tmpId && tmpId.startsWith("<at ")) {
|
|
15
|
+
if (tmpId.startsWith('<at ')) {
|
|
16
|
+
queryQQ = tmpId.replace('<at ', '');
|
|
17
|
+
}
|
|
18
|
+
let id = '';
|
|
19
|
+
const idStart = queryQQ.indexOf('id="');
|
|
20
|
+
if (idStart !== -1) {
|
|
21
|
+
const valueStart = idStart + 4;
|
|
22
|
+
const valueEnd = queryQQ.indexOf('"', valueStart);
|
|
23
|
+
if (valueEnd !== -1) {
|
|
24
|
+
id = queryQQ.substring(valueStart, valueEnd);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
queryQQ = id;
|
|
28
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, queryQQ);
|
|
29
|
+
if (!guildBindData) {
|
|
30
|
+
return `该用户没有绑定玩家编号`;
|
|
31
|
+
}
|
|
32
|
+
tmpId = guildBindData.tmp_id;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (tmpId && isNaN(tmpId)) {
|
|
36
|
+
return `请输入正确的玩家编号,或绑定玩家编号`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
40
|
+
if (!tmpId) {
|
|
41
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
42
|
+
if (!guildBindData) {
|
|
43
|
+
return `请输入正确的玩家编号,或绑定玩家编号`
|
|
44
|
+
}
|
|
45
|
+
tmpId = guildBindData.tmp_id
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 查询玩家信息
|
|
49
|
+
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId)
|
|
50
|
+
if (playerInfo.error && playerInfo.code === 10001) {
|
|
51
|
+
return '玩家不存在'
|
|
52
|
+
} else if (playerInfo.error) {
|
|
53
|
+
return '查询玩家信息失败,请重试'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 查询当日历史位置数据
|
|
57
|
+
const startTime = dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
|
58
|
+
const endTime = dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
|
59
|
+
let mapPlayerHistory = await evmOpenApi.mapPlayerHistory(ctx.http, tmpId, null, startTime, endTime)
|
|
60
|
+
if (mapPlayerHistory.error) {
|
|
61
|
+
return '查询玩家历史位置数据失败,请稍后重试'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 过滤非对应服务器数据
|
|
65
|
+
const promodsIdSet = new Set(PromodsIds)
|
|
66
|
+
const mapPlayerHistoryArr = mapPlayerHistory.data.filter(item => {
|
|
67
|
+
if (ServerType.ets === serverType) {
|
|
68
|
+
return !promodsIdSet.has(item.serverId)
|
|
69
|
+
} else if (ServerType.promods === serverType) {
|
|
70
|
+
return promodsIdSet.has(item.serverId)
|
|
71
|
+
}
|
|
72
|
+
return false
|
|
73
|
+
})
|
|
74
|
+
if (mapPlayerHistoryArr.length === 0) {
|
|
75
|
+
return `当日暂无数据`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 拼接数据
|
|
79
|
+
let data = {
|
|
80
|
+
mapType: ServerType.promods === serverType ? 'promods' : 'ets',
|
|
81
|
+
name: playerInfo.data.name,
|
|
82
|
+
smallAvatarUrl: playerInfo.data.smallAvatarUrl,
|
|
83
|
+
todayMileage: playerInfo.data.todayMileage,
|
|
84
|
+
points: mapPlayerHistory.data
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let page
|
|
88
|
+
try {
|
|
89
|
+
page = await ctx.puppeteer.page()
|
|
90
|
+
await page.setViewport({ width: 1000, height: 1000 })
|
|
91
|
+
await page.goto(`file:///${resolve(__dirname, '../resource/footprint.html')}`)
|
|
92
|
+
await page.evaluate(`init(${JSON.stringify(data)})`)
|
|
93
|
+
await common.sleep(100)
|
|
94
|
+
await page.waitForNetworkIdle()
|
|
95
|
+
const element = await page.$("#container");
|
|
96
|
+
return (
|
|
97
|
+
segment.image(await element.screenshot({
|
|
98
|
+
encoding: "binary"
|
|
99
|
+
}), "image/jpg")
|
|
100
|
+
)
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return '渲染异常,请重试'
|
|
103
|
+
} finally {
|
|
104
|
+
if (page) {
|
|
105
|
+
await page.close()
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return `OK: ` + playerInfo.data.name
|
|
109
|
+
}
|
|
@@ -1 +1,55 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { segment } = require('koishi');
|
|
2
|
+
const { resolve } = require('path');
|
|
3
|
+
const common = require('../util/common');
|
|
4
|
+
const evmOpenApi = require('../api/evmOpenApi');
|
|
5
|
+
const guildBind = require('../database/guildBind');
|
|
6
|
+
module.exports = async (ctx, session, rankingType) => {
|
|
7
|
+
if (!ctx.puppeteer) {
|
|
8
|
+
return '未启用 Puppeteer 功能';
|
|
9
|
+
}
|
|
10
|
+
// 查询排行榜信息
|
|
11
|
+
let mileageRankingList = await evmOpenApi.mileageRankingList(ctx.http, rankingType, null);
|
|
12
|
+
if (mileageRankingList.error) {
|
|
13
|
+
return '查询排行榜信息失败';
|
|
14
|
+
}
|
|
15
|
+
else if (mileageRankingList.data.length === 0) {
|
|
16
|
+
return '暂无数据';
|
|
17
|
+
}
|
|
18
|
+
// 查询当前玩家的排行信息
|
|
19
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
20
|
+
let playerMileageRanking = null;
|
|
21
|
+
if (guildBindData) {
|
|
22
|
+
let playerMileageRankingResult = await evmOpenApi.mileageRankingList(ctx.http, rankingType, guildBindData.tmp_id);
|
|
23
|
+
if (!playerMileageRankingResult.error && playerMileageRankingResult.data.length > 0) {
|
|
24
|
+
playerMileageRanking = playerMileageRankingResult.data[0];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// 拼接页面数据
|
|
28
|
+
let data = {
|
|
29
|
+
rankingType: rankingType,
|
|
30
|
+
mileageRankingList: mileageRankingList.data,
|
|
31
|
+
playerMileageRanking: playerMileageRanking
|
|
32
|
+
};
|
|
33
|
+
let page;
|
|
34
|
+
try {
|
|
35
|
+
page = await ctx.puppeteer.page();
|
|
36
|
+
await page.setViewport({ width: 1000, height: 1000 });
|
|
37
|
+
await page.goto(`file:///${resolve(__dirname, '../resource/mileage-leaderboard.html')}`);
|
|
38
|
+
await page.evaluate(`setData(${JSON.stringify(data)})`);
|
|
39
|
+
await page.waitForNetworkIdle();
|
|
40
|
+
await common.sleep(500);
|
|
41
|
+
const element = await page.$("#container");
|
|
42
|
+
return (segment.image(await element.screenshot({
|
|
43
|
+
encoding: "binary"
|
|
44
|
+
}), "image/jpg"));
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.info(e);
|
|
48
|
+
return '渲染异常,请重试';
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
if (page) {
|
|
52
|
+
await page.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -1 +1,123 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { segment } = require('koishi')
|
|
2
|
+
const { resolve } = require('path')
|
|
3
|
+
const guildBind = require('../database/guildBind')
|
|
4
|
+
const truckyAppApi = require('../api/truckyAppApi')
|
|
5
|
+
const truckersMpApi = require('../api/truckersMpApi')
|
|
6
|
+
const evmOpenApi = require('../api/evmOpenApi')
|
|
7
|
+
const baiduTranslate = require('../util/baiduTranslate')
|
|
8
|
+
const common = require('../util/common')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 定位
|
|
12
|
+
*/
|
|
13
|
+
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
14
|
+
if (ctx.puppeteer) {
|
|
15
|
+
if (tmpId && tmpId.startsWith("<at ")) {
|
|
16
|
+
if (tmpId.startsWith('<at ')) {
|
|
17
|
+
queryQQ = tmpId.replace('<at ', '');
|
|
18
|
+
}
|
|
19
|
+
let id = '';
|
|
20
|
+
const idStart = queryQQ.indexOf('id="');
|
|
21
|
+
if (idStart !== -1) {
|
|
22
|
+
const valueStart = idStart + 4;
|
|
23
|
+
const valueEnd = queryQQ.indexOf('"', valueStart);
|
|
24
|
+
if (valueEnd !== -1) {
|
|
25
|
+
id = queryQQ.substring(valueStart, valueEnd);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
queryQQ = id;
|
|
29
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, queryQQ);
|
|
30
|
+
if (!guildBindData) {
|
|
31
|
+
return `该用户没有绑定玩家编号`;
|
|
32
|
+
}
|
|
33
|
+
tmpId = guildBindData.tmp_id;
|
|
34
|
+
}
|
|
35
|
+
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
36
|
+
if (!tmpId) {
|
|
37
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
38
|
+
if (!guildBindData) {
|
|
39
|
+
return `请输入正确的玩家编号`
|
|
40
|
+
}
|
|
41
|
+
tmpId = guildBindData.tmp_id
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 查询玩家信息
|
|
45
|
+
let playerInfo = await truckersMpApi.player(ctx.http, tmpId)
|
|
46
|
+
if (playerInfo.error) {
|
|
47
|
+
return '查询玩家信息失败,请重试'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 查询线上信息
|
|
51
|
+
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId)
|
|
52
|
+
if (playerMapInfo.error) {
|
|
53
|
+
return '查询玩家线上信息失败,请重试'
|
|
54
|
+
}
|
|
55
|
+
if (!playerMapInfo.data.online) {
|
|
56
|
+
return '玩家离线'
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 查询周边玩家,并处理数据
|
|
60
|
+
let areaPlayersData = await evmOpenApi.mapPlayerList(ctx.http, playerMapInfo.data.server,
|
|
61
|
+
playerMapInfo.data.x - 4000,
|
|
62
|
+
playerMapInfo.data.y + 2500,
|
|
63
|
+
playerMapInfo.data.x + 4000,
|
|
64
|
+
playerMapInfo.data.y - 2500)
|
|
65
|
+
let areaPlayerList = []
|
|
66
|
+
if (!areaPlayersData.error) {
|
|
67
|
+
areaPlayerList = areaPlayersData.data
|
|
68
|
+
let index = areaPlayerList.findIndex((player) => {
|
|
69
|
+
return player.tmpId.toString() === tmpId.toString()
|
|
70
|
+
})
|
|
71
|
+
if (index !== -1) {
|
|
72
|
+
areaPlayerList.splice(index, 1)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
areaPlayerList.push({
|
|
76
|
+
axisX: playerMapInfo.data.x,
|
|
77
|
+
axisY: playerMapInfo.data.y,
|
|
78
|
+
tmpId
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// promods服ID集合
|
|
82
|
+
let promodsServerIdList = [50, 51]
|
|
83
|
+
|
|
84
|
+
// 构建地图数据
|
|
85
|
+
let data = {
|
|
86
|
+
mapType: promodsServerIdList.indexOf(playerMapInfo.data.server) !== -1 ? 'promods' : 'ets',
|
|
87
|
+
avatar: playerInfo.data.smallAvatar,
|
|
88
|
+
username: playerInfo.data.name,
|
|
89
|
+
serverName: playerMapInfo.data.serverDetails.name,
|
|
90
|
+
country: await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country),
|
|
91
|
+
realName: await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName),
|
|
92
|
+
currentPlayerId: tmpId,
|
|
93
|
+
centerX: playerMapInfo.data.x,
|
|
94
|
+
centerY: playerMapInfo.data.y,
|
|
95
|
+
playerList: areaPlayerList
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let page
|
|
99
|
+
try {
|
|
100
|
+
page = await ctx.puppeteer.page()
|
|
101
|
+
await page.setViewport({ width: 1000, height: 1000 })
|
|
102
|
+
await page.goto(`file:///${resolve(__dirname, '../resource/position.html')}`)
|
|
103
|
+
await page.evaluate(`setData(${JSON.stringify(data)})`)
|
|
104
|
+
await common.sleep(100)
|
|
105
|
+
await page.waitForNetworkIdle()
|
|
106
|
+
const element = await page.$("#container");
|
|
107
|
+
return (
|
|
108
|
+
segment.image(await element.screenshot({
|
|
109
|
+
encoding: "binary"
|
|
110
|
+
}), "image/jpg")
|
|
111
|
+
)
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return '渲染异常,请重试'
|
|
114
|
+
} finally {
|
|
115
|
+
if (page) {
|
|
116
|
+
await page.close()
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
} else {
|
|
121
|
+
return '未启用 puppeteer 服务'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const tmpQueryText = require("./tmpQueryText");
|
|
2
|
+
const tmpQueryImg = require("./tmpQueryImg");
|
|
3
|
+
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
4
|
+
switch (cfg.tmpQuery?.type) {
|
|
5
|
+
case 1:
|
|
6
|
+
return await tmpQueryText(ctx, cfg, session, tmpId);
|
|
7
|
+
case 2:
|
|
8
|
+
return await tmpQueryImg(ctx, cfg, session, tmpId);
|
|
9
|
+
default:
|
|
10
|
+
return '指令配置错误';
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -1 +1,103 @@
|
|
|
1
|
-
const
|
|
1
|
+
const dayjs = require('dayjs');
|
|
2
|
+
const guildBind = require('../../database/guildBind');
|
|
3
|
+
const truckyAppApi = require('../../api/truckyAppApi');
|
|
4
|
+
const evmOpenApi = require('../../api/evmOpenApi');
|
|
5
|
+
const baiduTranslate = require('../../util/baiduTranslate');
|
|
6
|
+
const { resolve } = require("path");
|
|
7
|
+
const common = require("../../util/common");
|
|
8
|
+
const { segment } = require("koishi");
|
|
9
|
+
/**
|
|
10
|
+
* 用户组
|
|
11
|
+
*/
|
|
12
|
+
const userGroup = {
|
|
13
|
+
'Player': '玩家',
|
|
14
|
+
'Retired Legend': '退役',
|
|
15
|
+
'Game Developer': '游戏开发者',
|
|
16
|
+
'Retired Team Member': '退休团队成员',
|
|
17
|
+
'Add-On Team': '附加组件团队',
|
|
18
|
+
'Game Moderator': '游戏管理员'
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 查询玩家信息
|
|
22
|
+
*/
|
|
23
|
+
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
24
|
+
if (!ctx.puppeteer) {
|
|
25
|
+
return '未启用 puppeteer 服务';
|
|
26
|
+
}
|
|
27
|
+
if (tmpId && isNaN(tmpId)) {
|
|
28
|
+
return `请输入正确的玩家编号`;
|
|
29
|
+
}
|
|
30
|
+
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
31
|
+
if (!tmpId) {
|
|
32
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
33
|
+
if (!guildBindData) {
|
|
34
|
+
return `请输入正确的玩家编号`;
|
|
35
|
+
}
|
|
36
|
+
tmpId = guildBindData.tmp_id;
|
|
37
|
+
}
|
|
38
|
+
// 查询玩家信息
|
|
39
|
+
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
|
|
40
|
+
if (playerInfo.error && playerInfo.code === 10001) {
|
|
41
|
+
return '玩家不存在';
|
|
42
|
+
}
|
|
43
|
+
else if (playerInfo.error) {
|
|
44
|
+
return '查询玩家信息失败,请重试';
|
|
45
|
+
}
|
|
46
|
+
// 查询线上信息
|
|
47
|
+
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId);
|
|
48
|
+
// 拼接数据
|
|
49
|
+
let data = {};
|
|
50
|
+
data.tmpId = playerInfo.data.tmpId;
|
|
51
|
+
data.name = playerInfo.data.name;
|
|
52
|
+
data.steamId = playerInfo.data.steamId;
|
|
53
|
+
data.registerDate = dayjs(playerInfo.data.registerTime).format('YYYY年MM月DD日');
|
|
54
|
+
data.avatarUrl = playerInfo.data.avatarUrl;
|
|
55
|
+
data.groupColor = playerInfo.data.groupColor;
|
|
56
|
+
data.groupName = (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName);
|
|
57
|
+
data.isJoinVtc = playerInfo.data.isJoinVtc;
|
|
58
|
+
data.vtcName = playerInfo.data.vtcName;
|
|
59
|
+
data.vtcRole = playerInfo.data.vtcRole;
|
|
60
|
+
data.isSponsor = playerInfo.data.isSponsor;
|
|
61
|
+
data.sponsorAmount = playerInfo.data.sponsorAmount;
|
|
62
|
+
data.sponsorCumulativeAmount = playerInfo.data.sponsorCumulativeAmount;
|
|
63
|
+
data.sponsorHide = playerInfo.data.sponsorHide;
|
|
64
|
+
data.isOnline = false;
|
|
65
|
+
if (playerMapInfo && !playerMapInfo.error) {
|
|
66
|
+
data.isOnline = playerMapInfo.data.online;
|
|
67
|
+
if (data.isOnline) {
|
|
68
|
+
data.onlineServerName = playerMapInfo.data.serverDetails.name;
|
|
69
|
+
data.onlineCountry = await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country);
|
|
70
|
+
data.onlineCity = await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName);
|
|
71
|
+
data.onlineX = playerMapInfo.data.x;
|
|
72
|
+
data.onlineY = playerMapInfo.data.y;
|
|
73
|
+
data.onlineMapType = playerMapInfo.data.serverDetails.id === 50 ? 'promods' : 'ets';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
data.isBan = playerInfo.data.isBan;
|
|
77
|
+
data.banUntil = playerInfo.data.banUntil;
|
|
78
|
+
data.banReason = playerInfo.data.banReason;
|
|
79
|
+
data.banReasonZh = playerInfo.data.banReasonZh;
|
|
80
|
+
data.banCount = playerInfo.data.banCount;
|
|
81
|
+
data.banHide = playerInfo.data.banHide;
|
|
82
|
+
let page;
|
|
83
|
+
try {
|
|
84
|
+
page = await ctx.puppeteer.page();
|
|
85
|
+
await page.setViewport({ width: 1000, height: 1000 });
|
|
86
|
+
await page.goto(`file:///${resolve(__dirname, '../../resource/query.html')}`);
|
|
87
|
+
await page.evaluate(`init(${JSON.stringify(data)})`);
|
|
88
|
+
await common.sleep(100);
|
|
89
|
+
await page.waitForNetworkIdle();
|
|
90
|
+
const element = await page.$("#container");
|
|
91
|
+
return (segment.image(await element.screenshot({
|
|
92
|
+
encoding: "binary"
|
|
93
|
+
}), "image/jpg"));
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return '渲染异常,请重试';
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (page) {
|
|
100
|
+
await page.close();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|