koishi-plugin-tmp-bot 1.16.3 → 1.16.5
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.d.ts +18 -0
- package/lib/api/evmOpenApi.js +67 -69
- package/lib/api/truckersMpApi.d.ts +34 -0
- package/lib/api/truckersMpApi.js +108 -113
- package/lib/api/truckersMpMapApi.d.ts +6 -0
- package/lib/api/truckersMpMapApi.js +23 -24
- package/lib/api/truckyAppApi.d.ts +12 -0
- package/lib/api/truckyAppApi.js +46 -47
- package/lib/command/tmpBind.d.ts +2 -0
- package/lib/command/tmpBind.js +13 -17
- package/lib/command/tmpDlcMap.d.ts +3 -0
- package/lib/command/tmpDlcMap.js +27 -29
- package/lib/command/tmpPosition.d.ts +3 -0
- package/lib/command/tmpPosition.js +90 -101
- package/lib/command/tmpQuery/tmpQuery.d.ts +2 -0
- package/lib/command/tmpQuery/tmpQuery.js +9 -10
- package/lib/command/tmpQuery/tmpQueryImg.d.ts +3 -0
- package/lib/command/tmpQuery/tmpQueryImg.js +88 -96
- package/lib/command/tmpQuery/tmpQueryText.d.ts +2 -0
- package/lib/command/tmpQuery/tmpQueryText.js +78 -82
- package/lib/command/tmpServer.d.ts +2 -0
- package/lib/command/tmpServer.js +31 -34
- package/lib/command/tmpTraffic/tmpTraffic.d.ts +2 -0
- package/lib/command/tmpTraffic/tmpTraffic.js +9 -10
- package/lib/command/tmpTraffic/tmpTrafficMap.d.ts +3 -0
- package/lib/command/tmpTraffic/tmpTrafficMap.js +101 -110
- package/lib/command/tmpTraffic/tmpTrafficText.d.ts +2 -0
- package/lib/command/tmpTraffic/tmpTrafficText.js +41 -49
- package/lib/command/tmpVersion.d.ts +2 -0
- package/lib/command/tmpVersion.js +12 -14
- package/lib/database/guildBind.d.ts +15 -0
- package/lib/database/guildBind.js +39 -40
- package/lib/database/model.d.ts +2 -0
- package/lib/database/model.js +55 -56
- package/lib/database/translateCache.d.ts +14 -0
- package/lib/database/translateCache.js +29 -31
- package/lib/resource/package/SEGUIEMJ.TTF +0 -0
- package/lib/resource/package/leaflet/heatmap.min.js +9 -0
- package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -0
- package/lib/resource/package/leaflet/leaflet.min.js +1 -0
- package/lib/resource/query.html +16 -6
- package/lib/util/baiduTranslate.d.ts +2 -0
- package/lib/util/baiduTranslate.js +28 -35
- package/lib/util/common.d.ts +1 -0
- package/lib/util/common.js +4 -4
- package/lib/util/constant.d.ts +4 -0
- package/lib/util/constant.js +8 -8
- package/package.json +1 -1
|
@@ -1,107 +1,96 @@
|
|
|
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
|
-
|
|
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');
|
|
10
9
|
/**
|
|
11
10
|
* 定位
|
|
12
11
|
*/
|
|
13
12
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (ctx.puppeteer) {
|
|
14
|
+
if (tmpId && isNaN(tmpId)) {
|
|
15
|
+
return `请输入正确的玩家编号`;
|
|
16
|
+
}
|
|
17
|
+
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
18
|
+
if (!tmpId) {
|
|
19
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
20
|
+
if (!guildBindData) {
|
|
21
|
+
return `请输入正确的玩家编号`;
|
|
22
|
+
}
|
|
23
|
+
tmpId = guildBindData.tmp_id;
|
|
24
|
+
}
|
|
25
|
+
// 查询玩家信息
|
|
26
|
+
let playerInfo = await truckersMpApi.player(ctx.http, tmpId);
|
|
27
|
+
if (playerInfo.error) {
|
|
28
|
+
return '查询玩家信息失败,请重试';
|
|
29
|
+
}
|
|
30
|
+
// 查询线上信息
|
|
31
|
+
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId);
|
|
32
|
+
if (playerMapInfo.error) {
|
|
33
|
+
return '查询玩家信息失败,请重试';
|
|
34
|
+
}
|
|
35
|
+
if (!playerMapInfo.data.online) {
|
|
36
|
+
return '玩家离线';
|
|
37
|
+
}
|
|
38
|
+
// 查询周边玩家,并处理数据
|
|
39
|
+
let areaPlayersData = await evmOpenApi.mapPlayerList(ctx.http, playerMapInfo.data.server, playerMapInfo.data.x - 4000, playerMapInfo.data.y + 2500, playerMapInfo.data.x + 4000, playerMapInfo.data.y - 2500);
|
|
40
|
+
let areaPlayerList = [];
|
|
41
|
+
if (!areaPlayersData.error) {
|
|
42
|
+
areaPlayerList = areaPlayersData.data;
|
|
43
|
+
let index = areaPlayerList.findIndex((player) => {
|
|
44
|
+
return player.tmpId.toString() === tmpId.toString();
|
|
45
|
+
});
|
|
46
|
+
if (index !== -1) {
|
|
47
|
+
areaPlayerList.splice(index, 1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
areaPlayerList.push({
|
|
51
|
+
axisX: playerMapInfo.data.x,
|
|
52
|
+
axisY: playerMapInfo.data.y,
|
|
53
|
+
tmpId
|
|
54
|
+
});
|
|
55
|
+
// promods服ID集合
|
|
56
|
+
let promodsServerIdList = [50, 51];
|
|
57
|
+
// 构建地图数据
|
|
58
|
+
let data = {
|
|
59
|
+
mapType: promodsServerIdList.indexOf(playerMapInfo.data.server) !== -1 ? 'promods' : 'ets',
|
|
60
|
+
avatar: playerInfo.data.smallAvatar,
|
|
61
|
+
username: playerInfo.data.name,
|
|
62
|
+
serverName: playerMapInfo.data.serverDetails.name,
|
|
63
|
+
country: await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country),
|
|
64
|
+
realName: await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName),
|
|
65
|
+
currentPlayerId: tmpId,
|
|
66
|
+
centerX: playerMapInfo.data.x,
|
|
67
|
+
centerY: playerMapInfo.data.y,
|
|
68
|
+
playerList: areaPlayerList
|
|
69
|
+
};
|
|
70
|
+
let page;
|
|
71
|
+
try {
|
|
72
|
+
page = await ctx.puppeteer.page();
|
|
73
|
+
await page.setViewport({ width: 1000, height: 1000 });
|
|
74
|
+
await page.goto(`file:///${resolve(__dirname, '../resource/position.html')}`);
|
|
75
|
+
await page.evaluate(`setData(${JSON.stringify(data)})`);
|
|
76
|
+
await common.sleep(100);
|
|
77
|
+
await page.waitForNetworkIdle();
|
|
78
|
+
const element = await page.$("#container");
|
|
79
|
+
return (segment.image(await element.screenshot({
|
|
80
|
+
encoding: "binary"
|
|
81
|
+
}), "image/jpg"));
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
console.info(e);
|
|
85
|
+
return '渲染异常,请重试';
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
if (page) {
|
|
89
|
+
await page.close();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
17
92
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!tmpId) {
|
|
21
|
-
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
22
|
-
if (!guildBindData) {
|
|
23
|
-
return `请输入正确的玩家编号`
|
|
24
|
-
}
|
|
25
|
-
tmpId = guildBindData.tmp_id
|
|
93
|
+
else {
|
|
94
|
+
return '未启用 puppeteer 服务';
|
|
26
95
|
}
|
|
27
|
-
|
|
28
|
-
// 查询玩家信息
|
|
29
|
-
let playerInfo = await truckersMpApi.player(ctx.http, tmpId)
|
|
30
|
-
if (playerInfo.error) {
|
|
31
|
-
return '查询玩家信息失败,请重试'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 查询线上信息
|
|
35
|
-
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId)
|
|
36
|
-
if (playerMapInfo.error) {
|
|
37
|
-
return '查询玩家信息失败,请重试'
|
|
38
|
-
}
|
|
39
|
-
if (!playerMapInfo.data.online) {
|
|
40
|
-
return '玩家离线'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 查询周边玩家,并处理数据
|
|
44
|
-
let areaPlayersData = await evmOpenApi.mapPlayerList(ctx.http, playerMapInfo.data.server,
|
|
45
|
-
playerMapInfo.data.x - 4000,
|
|
46
|
-
playerMapInfo.data.y + 2500,
|
|
47
|
-
playerMapInfo.data.x + 4000,
|
|
48
|
-
playerMapInfo.data.y - 2500)
|
|
49
|
-
let areaPlayerList = []
|
|
50
|
-
if (!areaPlayersData.error) {
|
|
51
|
-
areaPlayerList = areaPlayersData.data
|
|
52
|
-
let index = areaPlayerList.findIndex((player) => {
|
|
53
|
-
return player.tmpId.toString() === tmpId.toString()
|
|
54
|
-
})
|
|
55
|
-
if (index !== -1) {
|
|
56
|
-
areaPlayerList.splice(index, 1)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
areaPlayerList.push({
|
|
60
|
-
axisX: playerMapInfo.data.x,
|
|
61
|
-
axisY: playerMapInfo.data.y,
|
|
62
|
-
tmpId
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// promods服ID集合
|
|
66
|
-
let promodsServerIdList = [50, 51]
|
|
67
|
-
|
|
68
|
-
// 构建地图数据
|
|
69
|
-
let data = {
|
|
70
|
-
mapType: promodsServerIdList.indexOf(playerMapInfo.data.server) !== -1 ? 'promods' : 'ets',
|
|
71
|
-
avatar: playerInfo.data.smallAvatar,
|
|
72
|
-
username: playerInfo.data.name,
|
|
73
|
-
serverName: playerMapInfo.data.serverDetails.name,
|
|
74
|
-
country: await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country),
|
|
75
|
-
realName: await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName),
|
|
76
|
-
currentPlayerId: tmpId,
|
|
77
|
-
centerX: playerMapInfo.data.x,
|
|
78
|
-
centerY: playerMapInfo.data.y,
|
|
79
|
-
playerList: areaPlayerList
|
|
80
|
-
}
|
|
81
|
-
|
|
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/position.html')}`)
|
|
87
|
-
await page.evaluate(`setData(${JSON.stringify(data)})`)
|
|
88
|
-
await common.sleep(100)
|
|
89
|
-
await page.waitForNetworkIdle()
|
|
90
|
-
const element = await page.$("#container");
|
|
91
|
-
return (
|
|
92
|
-
segment.image(await element.screenshot({
|
|
93
|
-
encoding: "binary"
|
|
94
|
-
}), "image/jpg")
|
|
95
|
-
)
|
|
96
|
-
} catch (e) {
|
|
97
|
-
return '渲染异常,请重试'
|
|
98
|
-
} finally {
|
|
99
|
-
if (page) {
|
|
100
|
-
await page.close()
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
} else {
|
|
105
|
-
return '未启用 puppeteer 服务'
|
|
106
|
-
}
|
|
107
|
-
}
|
|
96
|
+
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const tmpQueryText = require("./tmpQueryText");
|
|
2
2
|
const tmpQueryImg = require("./tmpQueryImg");
|
|
3
|
-
|
|
4
3
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
4
|
+
switch (cfg.tmpQueryType) {
|
|
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,108 +1,100 @@
|
|
|
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");
|
|
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
7
|
const common = require("../../util/common");
|
|
8
|
-
const {segment} = require("koishi");
|
|
9
|
-
|
|
8
|
+
const { segment } = require("koishi");
|
|
10
9
|
/**
|
|
11
10
|
* 用户组
|
|
12
11
|
*/
|
|
13
12
|
const userGroup = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
13
|
+
'Player': '玩家',
|
|
14
|
+
'Retired Legend': '退役',
|
|
15
|
+
'Game Developer': '游戏开发者',
|
|
16
|
+
'Retired Team Member': '退休团队成员',
|
|
17
|
+
'Add-On Team': '附加组件团队',
|
|
18
|
+
'Game Moderator': '游戏管理员'
|
|
19
|
+
};
|
|
22
20
|
/**
|
|
23
21
|
* 查询玩家信息
|
|
24
22
|
*/
|
|
25
23
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (tmpId && isNaN(tmpId)) {
|
|
31
|
-
return `请输入正确的玩家编号`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
35
|
-
if (!tmpId) {
|
|
36
|
-
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
37
|
-
if (!guildBindData) {
|
|
38
|
-
return `请输入正确的玩家编号`
|
|
24
|
+
if (!ctx.puppeteer) {
|
|
25
|
+
return '未启用 puppeteer 服务';
|
|
39
26
|
}
|
|
40
|
-
tmpId
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// 查询玩家信息
|
|
44
|
-
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId)
|
|
45
|
-
if (playerInfo.error) {
|
|
46
|
-
return '查询玩家信息失败,请重试'
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 查询线上信息
|
|
50
|
-
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId)
|
|
51
|
-
|
|
52
|
-
// 拼接数据
|
|
53
|
-
let data = {}
|
|
54
|
-
data.tmpId = playerInfo.data.tmpId
|
|
55
|
-
data.name = playerInfo.data.name
|
|
56
|
-
data.steamId = playerInfo.data.steamId
|
|
57
|
-
data.registerDate = dayjs(playerInfo.data.registerTime).format('YYYY年MM月DD日')
|
|
58
|
-
data.avatarUrl = playerInfo.data.avatarUrl
|
|
59
|
-
data.groupColor = playerInfo.data.groupColor
|
|
60
|
-
data.groupName = (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName)
|
|
61
|
-
data.isJoinVtc = playerInfo.data.isJoinVtc
|
|
62
|
-
data.vtcName = playerInfo.data.vtcName
|
|
63
|
-
data.vtcRole = playerInfo.data.vtcRole
|
|
64
|
-
data.isSponsor = playerInfo.data.isSponsor
|
|
65
|
-
data.sponsorAmount = playerInfo.data.sponsorAmount
|
|
66
|
-
data.sponsorCumulativeAmount = playerInfo.data.sponsorCumulativeAmount
|
|
67
|
-
data.sponsorHide = playerInfo.data.sponsorHide
|
|
68
|
-
data.isOnline = false
|
|
69
|
-
if (playerMapInfo && !playerMapInfo.error) {
|
|
70
|
-
data.isOnline = playerMapInfo.data.online
|
|
71
|
-
if (data.isOnline) {
|
|
72
|
-
data.onlineServerName = playerMapInfo.data.serverDetails.name
|
|
73
|
-
data.onlineCountry = await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country)
|
|
74
|
-
data.onlineCity = await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName)
|
|
75
|
-
data.onlineX = playerMapInfo.data.x
|
|
76
|
-
data.onlineY = playerMapInfo.data.y
|
|
77
|
-
data.onlineMapType = playerMapInfo.data.serverDetails.id === 50 ? 'promods' : 'ets'
|
|
27
|
+
if (tmpId && isNaN(tmpId)) {
|
|
28
|
+
return `请输入正确的玩家编号`;
|
|
78
29
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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/query.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 {
|
|
102
|
-
return '渲染异常,请重试'
|
|
103
|
-
} finally {
|
|
104
|
-
if (page) {
|
|
105
|
-
await page.close()
|
|
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;
|
|
106
37
|
}
|
|
107
|
-
|
|
108
|
-
|
|
38
|
+
// 查询玩家信息
|
|
39
|
+
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
|
|
40
|
+
if (playerInfo.error) {
|
|
41
|
+
return '查询玩家信息失败,请重试';
|
|
42
|
+
}
|
|
43
|
+
// 查询线上信息
|
|
44
|
+
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId);
|
|
45
|
+
// 拼接数据
|
|
46
|
+
let data = {};
|
|
47
|
+
data.tmpId = playerInfo.data.tmpId;
|
|
48
|
+
data.name = playerInfo.data.name;
|
|
49
|
+
data.steamId = playerInfo.data.steamId;
|
|
50
|
+
data.registerDate = dayjs(playerInfo.data.registerTime).format('YYYY年MM月DD日');
|
|
51
|
+
data.avatarUrl = playerInfo.data.avatarUrl;
|
|
52
|
+
data.groupColor = playerInfo.data.groupColor;
|
|
53
|
+
data.groupName = (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName);
|
|
54
|
+
data.isJoinVtc = playerInfo.data.isJoinVtc;
|
|
55
|
+
data.vtcName = playerInfo.data.vtcName;
|
|
56
|
+
data.vtcRole = playerInfo.data.vtcRole;
|
|
57
|
+
data.isSponsor = playerInfo.data.isSponsor;
|
|
58
|
+
data.sponsorAmount = playerInfo.data.sponsorAmount;
|
|
59
|
+
data.sponsorCumulativeAmount = playerInfo.data.sponsorCumulativeAmount;
|
|
60
|
+
data.sponsorHide = playerInfo.data.sponsorHide;
|
|
61
|
+
data.isOnline = false;
|
|
62
|
+
if (playerMapInfo && !playerMapInfo.error) {
|
|
63
|
+
data.isOnline = playerMapInfo.data.online;
|
|
64
|
+
if (data.isOnline) {
|
|
65
|
+
data.onlineServerName = playerMapInfo.data.serverDetails.name;
|
|
66
|
+
data.onlineCountry = await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country);
|
|
67
|
+
data.onlineCity = await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName);
|
|
68
|
+
data.onlineX = playerMapInfo.data.x;
|
|
69
|
+
data.onlineY = playerMapInfo.data.y;
|
|
70
|
+
data.onlineMapType = playerMapInfo.data.serverDetails.id === 50 ? 'promods' : 'ets';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
data.isBan = playerInfo.data.isBan;
|
|
74
|
+
data.banUntil = playerInfo.data.banUntil;
|
|
75
|
+
data.banReason = playerInfo.data.banReason;
|
|
76
|
+
data.banReasonZh = playerInfo.data.banReasonZh;
|
|
77
|
+
data.banCount = playerInfo.data.banCount;
|
|
78
|
+
data.banHide = playerInfo.data.banHide;
|
|
79
|
+
let page;
|
|
80
|
+
try {
|
|
81
|
+
page = await ctx.puppeteer.page();
|
|
82
|
+
await page.setViewport({ width: 1000, height: 1000 });
|
|
83
|
+
await page.goto(`file:///${resolve(__dirname, '../../resource/query.html')}`);
|
|
84
|
+
await page.evaluate(`init(${JSON.stringify(data)})`);
|
|
85
|
+
await common.sleep(100);
|
|
86
|
+
await page.waitForNetworkIdle();
|
|
87
|
+
const element = await page.$("#container");
|
|
88
|
+
return (segment.image(await element.screenshot({
|
|
89
|
+
encoding: "binary"
|
|
90
|
+
}), "image/jpg"));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return '渲染异常,请重试';
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
if (page) {
|
|
97
|
+
await page.close();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -1,94 +1,90 @@
|
|
|
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
|
-
|
|
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');
|
|
7
6
|
/**
|
|
8
7
|
* 用户组
|
|
9
8
|
*/
|
|
10
9
|
const userGroup = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
10
|
+
'Player': '玩家',
|
|
11
|
+
'Retired Legend': '退役',
|
|
12
|
+
'Game Developer': '游戏开发者',
|
|
13
|
+
'Retired Team Member': '退休团队成员',
|
|
14
|
+
'Add-On Team': '附加组件团队',
|
|
15
|
+
'Game Moderator': '游戏管理员'
|
|
16
|
+
};
|
|
19
17
|
/**
|
|
20
18
|
* 查询玩家信息
|
|
21
19
|
*/
|
|
22
20
|
module.exports = async (ctx, cfg, session, tmpId) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
28
|
-
if (!tmpId) {
|
|
29
|
-
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId)
|
|
30
|
-
if (!guildBindData) {
|
|
31
|
-
return `请输入正确的玩家编号`
|
|
21
|
+
if (tmpId && isNaN(tmpId)) {
|
|
22
|
+
return `请输入正确的玩家编号`;
|
|
32
23
|
}
|
|
33
|
-
tmpId
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// 查询线上信息
|
|
43
|
-
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId)
|
|
44
|
-
|
|
45
|
-
// 拼接消息模板
|
|
46
|
-
let message = ''
|
|
47
|
-
if (cfg.queryShowAvatarEnable) {
|
|
48
|
-
message += `<img src="${playerInfo.data.avatarUrl}"/>\n`
|
|
49
|
-
}
|
|
50
|
-
message += '🆔TMP编号: ' + playerInfo.data.tmpId
|
|
51
|
-
message += '\n😀玩家名称: ' + playerInfo.data.name
|
|
52
|
-
message += '\n🎮SteamID: ' + playerInfo.data.steamId
|
|
53
|
-
let registerDate = dayjs(playerInfo.data.registerTime)
|
|
54
|
-
message += '\n📑注册日期: ' + registerDate.format('YYYY年MM月DD日') + ` (${dayjs().diff(registerDate, 'day')}天)`
|
|
55
|
-
message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName)
|
|
56
|
-
if (playerInfo.data.isJoinVtc) {
|
|
57
|
-
message += '\n🚚所属车队: ' + playerInfo.data.vtcName
|
|
58
|
-
message += '\n🚚车队角色: ' + playerInfo.data.vtcRole
|
|
59
|
-
}
|
|
60
|
-
message += '\n🚫是否封禁: ' + (playerInfo.data.isBan ? '是' : '否')
|
|
61
|
-
if (playerInfo.data.isBan) {
|
|
62
|
-
message += '\n🚫封禁截止: '
|
|
63
|
-
if (playerInfo.data.banHide) {
|
|
64
|
-
message += '隐藏'
|
|
65
|
-
} else {
|
|
66
|
-
if (!playerInfo.data.banUntil) {
|
|
67
|
-
message += '永久'
|
|
68
|
-
} else {
|
|
69
|
-
message += dayjs(playerInfo.data.banUntil).format('YYYY年MM月DD日 HH:mm')
|
|
70
|
-
}
|
|
71
|
-
message += "\n🚫封禁原因: " + (playerInfo.data.banReasonZh || playerInfo.data.banReason)
|
|
24
|
+
// 如果没有传入tmpId,尝试从数据库查询绑定信息
|
|
25
|
+
if (!tmpId) {
|
|
26
|
+
let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
|
|
27
|
+
if (!guildBindData) {
|
|
28
|
+
return `请输入正确的玩家编号`;
|
|
29
|
+
}
|
|
30
|
+
tmpId = guildBindData.tmp_id;
|
|
72
31
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (playerMapInfo.data.online) {
|
|
78
|
-
message += '\n🌍线上位置: '
|
|
79
|
-
message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country)
|
|
80
|
-
message += ' - '
|
|
81
|
-
message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName)
|
|
32
|
+
// 查询玩家信息
|
|
33
|
+
let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
|
|
34
|
+
if (playerInfo.error) {
|
|
35
|
+
return '查询玩家信息失败,请重试';
|
|
82
36
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
37
|
+
// 查询线上信息
|
|
38
|
+
let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId);
|
|
39
|
+
// 拼接消息模板
|
|
40
|
+
let message = '';
|
|
41
|
+
if (cfg.queryShowAvatarEnable) {
|
|
42
|
+
message += `<img src="${playerInfo.data.avatarUrl}"/>\n`;
|
|
88
43
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
message += '\n
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
44
|
+
message += '🆔TMP编号: ' + playerInfo.data.tmpId;
|
|
45
|
+
message += '\n😀玩家名称: ' + playerInfo.data.name;
|
|
46
|
+
message += '\n🎮SteamID: ' + playerInfo.data.steamId;
|
|
47
|
+
let registerDate = dayjs(playerInfo.data.registerTime);
|
|
48
|
+
message += '\n📑注册日期: ' + registerDate.format('YYYY年MM月DD日') + ` (${dayjs().diff(registerDate, 'day')}天)`;
|
|
49
|
+
message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName);
|
|
50
|
+
if (playerInfo.data.isJoinVtc) {
|
|
51
|
+
message += '\n🚚所属车队: ' + playerInfo.data.vtcName;
|
|
52
|
+
message += '\n🚚车队角色: ' + playerInfo.data.vtcRole;
|
|
53
|
+
}
|
|
54
|
+
message += '\n🚫是否封禁: ' + (playerInfo.data.isBan ? '是' : '否');
|
|
55
|
+
if (playerInfo.data.isBan) {
|
|
56
|
+
message += '\n🚫封禁截止: ';
|
|
57
|
+
if (playerInfo.data.banHide) {
|
|
58
|
+
message += '隐藏';
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (!playerInfo.data.banUntil) {
|
|
62
|
+
message += '永久';
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
message += dayjs(playerInfo.data.banUntil).format('YYYY年MM月DD日 HH:mm');
|
|
66
|
+
}
|
|
67
|
+
message += "\n🚫封禁原因: " + (playerInfo.data.banReasonZh || playerInfo.data.banReason);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
message += '\n🚫封禁次数: ' + playerInfo.data.banCount || 0;
|
|
71
|
+
if (playerMapInfo && !playerMapInfo.error) {
|
|
72
|
+
message += '\n📶在线状态: ' + (playerMapInfo.data.online ? `在线🟢 (${playerMapInfo.data.serverDetails.name})` : '离线⚫');
|
|
73
|
+
if (playerMapInfo.data.online) {
|
|
74
|
+
message += '\n🌍线上位置: ';
|
|
75
|
+
message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country);
|
|
76
|
+
message += ' - ';
|
|
77
|
+
message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (playerInfo.data.isSponsor) {
|
|
81
|
+
message += '\n🎁赞助用户';
|
|
82
|
+
if (!playerInfo.data.sponsorHide) {
|
|
83
|
+
message += `: \$${Math.floor(playerInfo.data.sponsorAmount / 100)}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (playerInfo.data.sponsorCumulativeAmount) {
|
|
87
|
+
message += '\n🎁累计赞助: $' + Math.floor(playerInfo.data.sponsorCumulativeAmount / 100);
|
|
88
|
+
}
|
|
89
|
+
return message;
|
|
90
|
+
};
|