koishi-plugin-lutu 1.0.0

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.
Files changed (62) hide show
  1. package/lib/api/evmOpenApi.d.ts +33 -0
  2. package/lib/api/evmOpenApi.js +114 -0
  3. package/lib/api/truckersMpApi.d.ts +34 -0
  4. package/lib/api/truckersMpApi.js +133 -0
  5. package/lib/api/truckersMpMapApi.d.ts +6 -0
  6. package/lib/api/truckersMpMapApi.js +25 -0
  7. package/lib/api/truckyAppApi.d.ts +12 -0
  8. package/lib/api/truckyAppApi.js +48 -0
  9. package/lib/command/ets-app/queryPoint.js +74 -0
  10. package/lib/command/ets-app/resetPassword.js +111 -0
  11. package/lib/command/tmpActivityService.js +603 -0
  12. package/lib/command/tmpBind.d.ts +2 -0
  13. package/lib/command/tmpBind.js +18 -0
  14. package/lib/command/tmpDlcMap.d.ts +3 -0
  15. package/lib/command/tmpDlcMap.js +33 -0
  16. package/lib/command/tmpMileageRanking.d.ts +3 -0
  17. package/lib/command/tmpMileageRanking.js +55 -0
  18. package/lib/command/tmpPosition.d.ts +3 -0
  19. package/lib/command/tmpPosition.js +107 -0
  20. package/lib/command/tmpQuery/tmpQuery.d.ts +2 -0
  21. package/lib/command/tmpQuery/tmpQuery.js +12 -0
  22. package/lib/command/tmpQuery/tmpQueryImg.d.ts +3 -0
  23. package/lib/command/tmpQuery/tmpQueryImg.js +103 -0
  24. package/lib/command/tmpQuery/tmpQueryText.d.ts +2 -0
  25. package/lib/command/tmpQuery/tmpQueryText.js +175 -0
  26. package/lib/command/tmpServer.d.ts +2 -0
  27. package/lib/command/tmpServer.js +41 -0
  28. package/lib/command/tmpTraffic/tmpTraffic.d.ts +2 -0
  29. package/lib/command/tmpTraffic/tmpTraffic.js +15 -0
  30. package/lib/command/tmpTraffic/tmpTrafficMap.d.ts +3 -0
  31. package/lib/command/tmpTraffic/tmpTrafficMap.js +163 -0
  32. package/lib/command/tmpTraffic/tmpTrafficText.d.ts +2 -0
  33. package/lib/command/tmpTraffic/tmpTrafficText.js +60 -0
  34. package/lib/command/tmpVersion.d.ts +2 -0
  35. package/lib/command/tmpVersion.js +14 -0
  36. package/lib/command/tmpVtc.js +29 -0
  37. package/lib/database/guildBind.d.ts +15 -0
  38. package/lib/database/guildBind.js +41 -0
  39. package/lib/database/model.d.ts +2 -0
  40. package/lib/database/model.js +65 -0
  41. package/lib/database/translateCache.d.ts +14 -0
  42. package/lib/database/translateCache.js +31 -0
  43. package/lib/index.d.ts +35 -0
  44. package/lib/index.js +276 -0
  45. package/lib/resource/dlc.html +115 -0
  46. package/lib/resource/mileage-leaderboard.html +363 -0
  47. package/lib/resource/package/SEGUIEMJ.TTF +0 -0
  48. package/lib/resource/package/leaflet/heatmap.min.js +9 -0
  49. package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -0
  50. package/lib/resource/package/leaflet/leaflet.min.css +1 -0
  51. package/lib/resource/package/leaflet/leaflet.min.js +1 -0
  52. package/lib/resource/position.html +223 -0
  53. package/lib/resource/query.html +363 -0
  54. package/lib/resource/traffic.html +207 -0
  55. package/lib/util/baiduTranslate.d.ts +2 -0
  56. package/lib/util/baiduTranslate.js +30 -0
  57. package/lib/util/common.d.ts +1 -0
  58. package/lib/util/common.js +5 -0
  59. package/lib/util/constant.d.ts +8 -0
  60. package/lib/util/constant.js +16 -0
  61. package/package.json +41 -0
  62. package/readme.md +143 -0
@@ -0,0 +1,55 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<segment | "请输入正确的玩家编号" | "渲染异常,请重试" | "查询玩家信息失败,请重试" | "玩家离线" | "未启用 puppeteer 服务">;
2
+ export = _exports;
3
+ import { segment } from "@koishijs/core";
@@ -0,0 +1,107 @@
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 && isNaN(tmpId)) {
16
+ return `请输入正确的玩家编号`
17
+ }
18
+
19
+ // 如果没有传入tmpId,尝试从数据库查询绑定信息
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
26
+ }
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
+ }
@@ -0,0 +1,2 @@
1
+ declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<string | import("koishi").Element>;
2
+ export = _exports;
@@ -0,0 +1,12 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<segment | "请输入正确的玩家编号" | "渲染异常,请重试" | "查询玩家信息失败,请重试" | "未启用 puppeteer 服务" | "玩家不存在">;
2
+ export = _exports;
3
+ import { segment } from "@koishijs/core";
@@ -0,0 +1,103 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<string>;
2
+ export = _exports;
@@ -0,0 +1,175 @@
1
+ const dayjs = require('dayjs');
2
+ const dayjsRelativeTime = require('dayjs/plugin/relativeTime');
3
+ const dayjsLocaleZhCn = require('dayjs/locale/zh-cn');
4
+ const guildBind = require('../../database/guildBind');
5
+ const truckyAppApi = require('../../api/truckyAppApi');
6
+ const evmOpenApi = require('../../api/evmOpenApi');
7
+ const baiduTranslate = require('../../util/baiduTranslate');
8
+ dayjs.extend(dayjsRelativeTime);
9
+ dayjs.locale(dayjsLocaleZhCn);
10
+ /**
11
+ * 用户组
12
+ */
13
+ const userGroup = {
14
+ 'Player': '玩家',
15
+ 'Retired Legend': '退役',
16
+ 'Game Developer': '游戏开发者',
17
+ 'Retired Team Member': '退休团队成员',
18
+ 'Add-On Team': '附加组件团队',
19
+ 'Game Moderator': '游戏管理员'
20
+ };
21
+ /**
22
+ * 查询玩家信息
23
+ */
24
+ module.exports = async (ctx, cfg, session, tmpId) => {
25
+ if (tmpId && tmpId.startsWith("<at ")) {
26
+ if (tmpId.startsWith('<at ')) {
27
+ queryQQ = tmpId.replace('<at ', '');
28
+ }
29
+ let id = '';
30
+ const idStart = queryQQ.indexOf('id="');
31
+ if (idStart !== -1) {
32
+ const valueStart = idStart + 4;
33
+ const valueEnd = queryQQ.indexOf('"', valueStart);
34
+ if (valueEnd !== -1) {
35
+ id = queryQQ.substring(valueStart, valueEnd);
36
+ }
37
+ }
38
+ queryQQ = id;
39
+ let guildBindData = await guildBind.get(ctx.database, session.platform, queryQQ);
40
+ if (!guildBindData) {
41
+ return `该用户没有绑定玩家编号`;
42
+ }
43
+ tmpId = guildBindData.tmp_id;
44
+ }
45
+ // 如果没有传入tmpId,尝试从数据库查询绑定信息
46
+ if (!tmpId) {
47
+ let guildBindData = await guildBind.get(ctx.database, session.platform, session.userId);
48
+ if (!guildBindData) {
49
+ return `请输入正确的玩家编号`;
50
+ }
51
+ tmpId = guildBindData.tmp_id;
52
+ }
53
+ // 查询玩家信息
54
+ let playerInfo = await evmOpenApi.playerInfo(ctx.http, tmpId);
55
+ if (playerInfo.error && playerInfo.code === 10001) {
56
+ return '玩家不存在';
57
+ }
58
+ else if (playerInfo.error) {
59
+ return '查询玩家信息失败,请重试';
60
+ }
61
+ // 查询线上信息
62
+ let playerMapInfo = await truckyAppApi.online(ctx.http, tmpId);
63
+ // 拼接消息模板
64
+ let message = '';
65
+ if (cfg.tmpQuery?.showAvatar) {
66
+ message += `<img src="${playerInfo.data.avatarUrl}"/>\n`;
67
+ }
68
+ message += '🆔TMP编号: ' + playerInfo.data.tmpId;
69
+ message += '\n😀玩家名称: ' + playerInfo.data.name;
70
+ message += '\n🎮SteamID: ' + playerInfo.data.steamId;
71
+ let registerDate = dayjs(playerInfo.data.registerTime);
72
+ message += '\n📑注册日期: ' + registerDate.format('YYYY年MM月DD日') + ` (${dayjs().diff(registerDate, 'day')}天)`;
73
+ message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName);
74
+ if (playerInfo.data.isJoinVtc) {
75
+ message += '\n🚚所属车队: ' + playerInfo.data.vtcName;
76
+ if (playerInfo.data.vtcHistory && playerInfo.data.vtcHistory.length > 0) {
77
+ message += `\n📜历史车队:\n${playerInfo.data.vtcHistory.map(vtc => `- ${vtc.vtcName}\n(加入时间: ${dayjs(vtc.joinDate).format('YYYY年MM月DD日')}, 离开日期: ${dayjs(vtc.quitDate).format('YYYY年MM月DD日')})`).join('\n')}`
78
+ }
79
+ message += '\n🚚车队角色: ' + playerInfo.data.vtcRole;
80
+ if (playerInfo.data.vtcId == 74950) {
81
+ const { url, token, logOutput } = cfg.mainSettings?.settings || {};
82
+ try {
83
+ if (logOutput) {
84
+ ctx.logger.info(`tmpQuery:开始查询TmpID ${tmpId} 的积分`);
85
+ }
86
+ const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=${tmpId}&tmpName=&teamId=&qq=&state=0&teamRole=`;
87
+ if (logOutput) {
88
+ ctx.logger.info(`请求用户信息: ${userInfoUrl}`);
89
+ }
90
+ const userInfoResponse = await ctx.http.post(userInfoUrl);
91
+ if (logOutput) {
92
+ ctx.logger.info(`用户信息响应: ${JSON.stringify(userInfoResponse)}`);
93
+ }
94
+ const userList = userInfoResponse.page?.list || [];
95
+ const userInfo = userList[0];
96
+ const rewardPoints = userInfo.rewardPoints || 0;
97
+ message += `\n⭐ 当前车队积分: ${rewardPoints}`;
98
+ } catch (error) {
99
+ ctx.logger.error(`积分查询过程出错: ${error}`);
100
+ if (error.response) {
101
+ message += '查询出错';
102
+ }
103
+ }
104
+ }
105
+ }
106
+ message += '\n\n🚫是否封禁: ' + (playerInfo.data.isBan ? '是' : '否');
107
+ if (playerInfo.data.isBan) {
108
+ message += '\n🚫封禁截止: ';
109
+ if (playerInfo.data.banHide) {
110
+ message += '隐藏';
111
+ }
112
+ else {
113
+ if (!playerInfo.data.banUntil) {
114
+ message += '永久';
115
+ }
116
+ else {
117
+ message += dayjs(playerInfo.data.banUntil).format('YYYY年MM月DD日 HH:mm');
118
+ }
119
+ message += "\n🚫封禁原因: " + (playerInfo.data.banReasonZh || playerInfo.data.banReason);
120
+ }
121
+ }
122
+ message += '\n🚫封禁次数: ' + (playerInfo.data.banCount || 0);
123
+ if (playerInfo.data.mileage) {
124
+ let mileage = playerInfo.data.mileage;
125
+ let mileageUnit = '米';
126
+ if (mileage > 1000) {
127
+ mileage = (mileage / 1000).toFixed(1);
128
+ mileageUnit = '公里';
129
+ }
130
+ message += '\n\n🚩历史里程: ' + mileage + mileageUnit;
131
+ }
132
+ if (playerInfo.data.todayMileage) {
133
+ let todayMileage = playerInfo.data.todayMileage;
134
+ let mileageUnit = '米';
135
+ if (todayMileage > 1000) {
136
+ todayMileage = (todayMileage / 1000).toFixed(1);
137
+ mileageUnit = '公里';
138
+ }
139
+ message += '\n🚩今日里程: ' + todayMileage + mileageUnit;
140
+ }
141
+ if (playerMapInfo && !playerMapInfo.error) {
142
+ message += '\n📶在线状态: ' + (playerMapInfo.data.online ? `在线🟢 (${playerMapInfo.data.serverDetails.name})` : '离线⚫');
143
+ if (playerMapInfo.data.online) {
144
+ message += '\n🌍线上位置: ';
145
+ message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.country);
146
+ message += ' - ';
147
+ message += await baiduTranslate(ctx, cfg, playerMapInfo.data.location.poi.realName);
148
+ }
149
+ else if (playerInfo.data.lastOnlineTime) {
150
+ message += '\n📶上次在线: ' + dayjs(playerInfo.data.lastOnlineTime).fromNow(false);
151
+ }
152
+ }
153
+ message += '\n\n🌟是否Patreon支持者: '
154
+ if (playerInfo.data.isSponsor) {
155
+ message += '是'
156
+ }
157
+ else {
158
+ message += '否'
159
+ }
160
+ message += '\n💰当前赞助金额: '
161
+ if (playerInfo.data.sponsorAmount == 'null') {
162
+ message += '0美金'
163
+ }
164
+ else {
165
+ message += playerInfo.data.sponsorAmount / 100 + '美金'
166
+ }
167
+ message += '\n💰全部赞助金额: '
168
+ if (playerInfo.data.sponsorCumulativeAmount == 'null') {
169
+ message += '0美金'
170
+ }
171
+ else {
172
+ message += playerInfo.data.sponsorCumulativeAmount / 100 + '美金'
173
+ }
174
+ return message;
175
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(ctx: any): Promise<string>;
2
+ export = _exports;
@@ -0,0 +1,41 @@
1
+ const truckersMpApi = require('../api/truckersMpApi')
2
+
3
+ module.exports = async (ctx, cfg, game) => {
4
+ // 查询服务器信息
5
+ let serverData = await truckersMpApi.servers(ctx.http)
6
+ if (serverData.error) {
7
+ return '查询服务器失败,请稍后重试'
8
+ }
9
+
10
+ // 过滤服务器
11
+ let etsServerList = serverData.data.filter(server => server.game === game)
12
+
13
+ // 构建消息
14
+ let message = ''
15
+ for (let server of etsServerList) {
16
+ // 如果前面有内容,换行
17
+ if (message) {
18
+ message += '\n\n'
19
+ }
20
+
21
+ message += '服务器: ' + ( server.online ? '🟢' : '⚫' ) + server.name
22
+ message += `\n服务器ID: ${server.id}`
23
+ message += `\n服务器IP: ${server.ip}`
24
+ message += `\n玩家人数: ${server.players}/${server.maxplayers}`
25
+ if (server.queue) {
26
+ message += ` (队列: ${server.queue})`
27
+ }
28
+ // 服务器特性
29
+ let characteristicList = []
30
+ if (!server.afkenabled) {
31
+ characteristicList.push('⏱挂机')
32
+ }
33
+ if (server.collisions) {
34
+ characteristicList.push('💥碰撞')
35
+ }
36
+ if (characteristicList && characteristicList.length > 0) {
37
+ message += '\n服务器特性: ' + characteristicList.join(' ')
38
+ }
39
+ }
40
+ return message
41
+ }
@@ -0,0 +1,2 @@
1
+ declare function _exports(ctx: any, cfg: any, serverName: any): Promise<string | import("koishi").Element>;
2
+ export = _exports;
@@ -0,0 +1,15 @@
1
+ const tmpTrafficMap = require("./tmpTrafficMap");
2
+ const tmpTrafficText = require("./tmpTrafficText");
3
+ /**
4
+ * 查询路况
5
+ */
6
+ module.exports = async (ctx, cfg, serverName) => {
7
+ switch (cfg.tmpTraffic?.type) {
8
+ case 1:
9
+ return await tmpTrafficText(ctx, cfg, serverName);
10
+ case 2:
11
+ return await tmpTrafficMap(ctx, cfg, serverName);
12
+ default:
13
+ return '指令配置错误';
14
+ }
15
+ };
@@ -0,0 +1,3 @@
1
+ declare function _exports(ctx: any, cfg: any, serverName: any): Promise<segment | "渲染异常,请重试" | "未启用 puppeteer 服务" | "请输入正确的服务器名称 (s1, s2, p, a)" | "查询路况信息失败">;
2
+ export = _exports;
3
+ import { segment } from "@koishijs/core";