koishi-plugin-ets2-tools-tmp 0.0.2 → 0.0.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.
Files changed (60) 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 +174 -0
  11. package/lib/command/tmpBind.d.ts +2 -0
  12. package/lib/command/tmpBind.js +18 -0
  13. package/lib/command/tmpDlcMap.d.ts +3 -0
  14. package/lib/command/tmpDlcMap.js +33 -0
  15. package/lib/command/tmpMileageRanking.d.ts +3 -0
  16. package/lib/command/tmpMileageRanking.js +55 -0
  17. package/lib/command/tmpPosition.d.ts +3 -0
  18. package/lib/command/tmpPosition.js +107 -0
  19. package/lib/command/tmpQuery/tmpQuery.d.ts +2 -0
  20. package/lib/command/tmpQuery/tmpQuery.js +12 -0
  21. package/lib/command/tmpQuery/tmpQueryImg.d.ts +3 -0
  22. package/lib/command/tmpQuery/tmpQueryImg.js +103 -0
  23. package/lib/command/tmpQuery/tmpQueryText.d.ts +2 -0
  24. package/lib/command/tmpQuery/tmpQueryText.js +178 -0
  25. package/lib/command/tmpServer.d.ts +2 -0
  26. package/lib/command/tmpServer.js +41 -0
  27. package/lib/command/tmpTraffic/tmpTraffic.d.ts +2 -0
  28. package/lib/command/tmpTraffic/tmpTraffic.js +15 -0
  29. package/lib/command/tmpTraffic/tmpTrafficMap.d.ts +3 -0
  30. package/lib/command/tmpTraffic/tmpTrafficMap.js +167 -0
  31. package/lib/command/tmpTraffic/tmpTrafficText.d.ts +2 -0
  32. package/lib/command/tmpTraffic/tmpTrafficText.js +58 -0
  33. package/lib/command/tmpVersion.d.ts +2 -0
  34. package/lib/command/tmpVersion.js +14 -0
  35. package/lib/command/tmpVtc.js +29 -0
  36. package/lib/database/guildBind.d.ts +15 -0
  37. package/lib/database/guildBind.js +41 -0
  38. package/lib/database/model.d.ts +2 -0
  39. package/lib/database/model.js +65 -0
  40. package/lib/database/translateCache.d.ts +14 -0
  41. package/lib/database/translateCache.js +31 -0
  42. package/lib/index.d.ts +14 -0
  43. package/lib/index.js +75 -0
  44. package/lib/resource/dlc.html +115 -0
  45. package/lib/resource/mileage-leaderboard.html +363 -0
  46. package/lib/resource/package/SEGUIEMJ.TTF +0 -0
  47. package/lib/resource/package/leaflet/heatmap.min.js +9 -0
  48. package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -0
  49. package/lib/resource/package/leaflet/leaflet.min.css +1 -0
  50. package/lib/resource/package/leaflet/leaflet.min.js +1 -0
  51. package/lib/resource/position.html +223 -0
  52. package/lib/resource/query.html +363 -0
  53. package/lib/resource/traffic.html +204 -0
  54. package/lib/util/baiduTranslate.d.ts +2 -0
  55. package/lib/util/baiduTranslate.js +30 -0
  56. package/lib/util/common.d.ts +1 -0
  57. package/lib/util/common.js +5 -0
  58. package/lib/util/constant.d.ts +8 -0
  59. package/lib/util/constant.js +16 -0
  60. package/package.json +4 -4
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 查询服务器列表
3
+ */
4
+ export function serverList(http: any): Promise<{
5
+ error: boolean;
6
+ }>;
7
+ /**
8
+ * 查询在线玩家
9
+ */
10
+ export function mapPlayerList(http: any, serverId: any, ax: any, ay: any, bx: any, by: any): Promise<{
11
+ error: boolean;
12
+ }>;
13
+ /**
14
+ * 查询玩家信息
15
+ */
16
+ export function playerInfo(http: any, tmpId: any): Promise<{
17
+ code: any;
18
+ error: boolean;
19
+ } | {
20
+ error: boolean;
21
+ }>;
22
+ /**
23
+ * DLC列表
24
+ */
25
+ export function dlcList(http: any, type: any): Promise<{
26
+ error: boolean;
27
+ }>;
28
+ /**
29
+ * 玩家里程排行
30
+ */
31
+ export function mileageRankingList(http: any, rankingType: any, tmpId: any): Promise<{
32
+ error: boolean;
33
+ }>;
@@ -0,0 +1,114 @@
1
+ const BASE_API = 'https://da.vtcm.link';
2
+ module.exports = {
3
+ /**
4
+ * 查询服务器列表
5
+ */
6
+ async serverList(http) {
7
+ let result = null;
8
+ try {
9
+ result = await http.get(`${BASE_API}/server/list`);
10
+ }
11
+ catch {
12
+ return {
13
+ error: true
14
+ };
15
+ }
16
+ // 拼接返回数据
17
+ let data = {
18
+ error: result.code !== 200
19
+ };
20
+ if (!data.error) {
21
+ data.data = result.data;
22
+ }
23
+ return data;
24
+ },
25
+ /**
26
+ * 查询在线玩家
27
+ */
28
+ async mapPlayerList(http, serverId, ax, ay, bx, by) {
29
+ let result = null;
30
+ try {
31
+ result = await http.get(`${BASE_API}/map/playerList?aAxisX=${ax}&aAxisY=${ay}&bAxisX=${bx}&bAxisY=${by}&serverId=${serverId}`);
32
+ }
33
+ catch {
34
+ return {
35
+ error: true
36
+ };
37
+ }
38
+ // 拼接返回数据
39
+ let data = {
40
+ error: result.code !== 200
41
+ };
42
+ if (!data.error) {
43
+ data.data = result.data;
44
+ }
45
+ return data;
46
+ },
47
+ /**
48
+ * 查询玩家信息
49
+ */
50
+ async playerInfo(http, tmpId) {
51
+ let result = null;
52
+ try {
53
+ result = await http.get(`https://da.vtcm.link/player/info?tmpId=${tmpId}`);
54
+ }
55
+ catch {
56
+ return {
57
+ error: true
58
+ };
59
+ }
60
+ // 拼接返回数据
61
+ let data = {
62
+ code: result.code,
63
+ error: result.code !== 200
64
+ };
65
+ if (!data.error) {
66
+ data.data = result.data;
67
+ }
68
+ return data;
69
+ },
70
+ /**
71
+ * DLC列表
72
+ */
73
+ async dlcList(http, type) {
74
+ let result = null;
75
+ try {
76
+ result = await http.get(`${BASE_API}/dlc/list?type=${type}`);
77
+ }
78
+ catch (e) {
79
+ return {
80
+ error: true
81
+ };
82
+ }
83
+ // 拼接返回数据
84
+ let data = {
85
+ error: result.code !== 200
86
+ };
87
+ if (!data.error) {
88
+ data.data = result.data;
89
+ }
90
+ return data;
91
+ },
92
+ /**
93
+ * 玩家里程排行
94
+ */
95
+ async mileageRankingList(http, rankingType, tmpId) {
96
+ let result = null;
97
+ try {
98
+ result = await http.get(`${BASE_API}/statistics/mileageRankingList?rankingType=${rankingType}&tmpId=${tmpId || ''}&rankingCount=10`);
99
+ }
100
+ catch (e) {
101
+ return {
102
+ error: true
103
+ };
104
+ }
105
+ // 拼接返回数据
106
+ let data = {
107
+ error: result.code !== 200
108
+ };
109
+ if (!data.error) {
110
+ data.data = result.data;
111
+ }
112
+ return data;
113
+ }
114
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 查询玩家信息
3
+ */
4
+ export function player(http: any, tmpId: any): Promise<{
5
+ error: any;
6
+ }>;
7
+ /**
8
+ * 查询服务器列表
9
+ */
10
+ export function servers(http: any): Promise<{
11
+ error: any;
12
+ }>;
13
+ /**
14
+ * 查询玩家封禁信息
15
+ */
16
+ export function bans(http: any, tmpId: any): Promise<{
17
+ error: any;
18
+ }>;
19
+ /**
20
+ * 游戏版本
21
+ */
22
+ export function version(http: any): Promise<{
23
+ error: boolean;
24
+ data?: undefined;
25
+ } | {
26
+ error: boolean;
27
+ data: any;
28
+ }>;
29
+ /**
30
+ * 查询车队成员信息
31
+ */
32
+ export function vtcMember(http: any, vtcId: any, memberId: any): Promise<{
33
+ error: any;
34
+ }>;
@@ -0,0 +1,133 @@
1
+ const BASE_API = 'https://api.truckersmp.com/v2';
2
+ module.exports = {
3
+ /**
4
+ * 查询玩家信息
5
+ */
6
+ async player(http, tmpId) {
7
+ let result = null;
8
+ try {
9
+ result = await http.get(`${BASE_API}/player/${tmpId}`);
10
+ }
11
+ catch {
12
+ return {
13
+ error: true
14
+ };
15
+ }
16
+ // 拼接返回数据
17
+ let data = {
18
+ error: JSON.parse(result.error)
19
+ };
20
+ if (!data.error) {
21
+ data.data = result.response;
22
+ }
23
+ return data;
24
+ },
25
+ /**
26
+ * 查询服务器列表
27
+ */
28
+ async servers(http) {
29
+ let result = null;
30
+ try {
31
+ result = await http.get(`${BASE_API}/servers`);
32
+ }
33
+ catch {
34
+ return {
35
+ error: true
36
+ };
37
+ }
38
+ // 拼接返回数据
39
+ let data = {
40
+ error: JSON.parse(result.error)
41
+ };
42
+ if (!data.error) {
43
+ data.data = result.response;
44
+ }
45
+ return data;
46
+ },
47
+ /**
48
+ * 查询玩家封禁信息
49
+ */
50
+ async bans(http, tmpId) {
51
+ let result = null;
52
+ try {
53
+ result = await http.get(`${BASE_API}/bans/${tmpId}`);
54
+ }
55
+ catch {
56
+ return {
57
+ error: true
58
+ };
59
+ }
60
+ // 拼接返回数据
61
+ let data = {
62
+ error: JSON.parse(result.error)
63
+ };
64
+ if (!data.error) {
65
+ data.data = result.response;
66
+ }
67
+ return data;
68
+ },
69
+ /**
70
+ * 游戏版本
71
+ */
72
+ async version(http) {
73
+ let result = null;
74
+ try {
75
+ result = await http.get(`${BASE_API}/version`);
76
+ }
77
+ catch {
78
+ return {
79
+ error: true
80
+ };
81
+ }
82
+ // 拼接返回数据
83
+ return {
84
+ error: false,
85
+ data: result
86
+ };
87
+ },
88
+ /**
89
+ * 查询车队成员信息
90
+ */
91
+ async vtcMember(http, vtcId, memberId) {
92
+ let result = null;
93
+ try {
94
+ result = await http.get(`${BASE_API}/vtc/${vtcId}/member/${memberId}`);
95
+ }
96
+ catch {
97
+ return {
98
+ error: true
99
+ };
100
+ }
101
+ // 拼接返回数据
102
+ let data = {
103
+ error: JSON.parse(result.error)
104
+ };
105
+ if (!data.error) {
106
+ data.data = result.response;
107
+ }
108
+ return data;
109
+ },
110
+ /*
111
+ * 查询vtc信息
112
+ */
113
+ async vtc(http, vtcId) {
114
+ let result = null
115
+ try {
116
+ result = await http.get(`${BASE_API}/vtc/${vtcId}`)
117
+ } catch {
118
+ return {
119
+ error: true
120
+ }
121
+ }
122
+
123
+ // 拼接返回数据
124
+ let data = {
125
+ error: JSON.parse(result.error)
126
+ }
127
+ if (!data.error) {
128
+ data.data = result.response
129
+ }
130
+
131
+ return data
132
+ }
133
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 区域查询玩家
3
+ */
4
+ export function area(http: any, serverId: any, x1: any, y1: any, x2: any, y2: any): Promise<{
5
+ error: boolean;
6
+ }>;
@@ -0,0 +1,25 @@
1
+ const BASE_API = 'https://tracker.ets2map.com';
2
+ module.exports = {
3
+ /**
4
+ * 区域查询玩家
5
+ */
6
+ async area(http, serverId, x1, y1, x2, y2) {
7
+ let result = null;
8
+ try {
9
+ result = await http.get(`${BASE_API}/v3/area?x1=${x1}&y1=${y1}&x2=${x2}&y2=${y2}&server=${serverId}`);
10
+ }
11
+ catch {
12
+ return {
13
+ error: true
14
+ };
15
+ }
16
+ // 拼接返回数据
17
+ let data = {
18
+ error: !result || !result.Success
19
+ };
20
+ if (!data.error) {
21
+ data.data = result.Data;
22
+ }
23
+ return data;
24
+ }
25
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 查询线上信息
3
+ */
4
+ export function online(http: any, tmpId: any): Promise<{
5
+ error: any;
6
+ }>;
7
+ /**
8
+ * 查询热门交通数据
9
+ */
10
+ export function trafficTop(http: any, serverName: any): Promise<{
11
+ error: boolean;
12
+ }>;
@@ -0,0 +1,48 @@
1
+ const BASE_API = 'https://api.codetabs.com/v1/proxy/?quest=https://api.truckyapp.com'
2
+
3
+ module.exports = {
4
+ /**
5
+ * 查询线上信息
6
+ */
7
+ async online (http, tmpId) {
8
+ let result = null
9
+ try {
10
+ result = await http.get(`${BASE_API}/v3/map/online?playerID=${tmpId}`)
11
+ } catch {
12
+ return {
13
+ error: true
14
+ }
15
+ }
16
+
17
+ // 拼接返回数据
18
+ let data = {
19
+ error: !result || !result.response || result.response.error
20
+ }
21
+ if (!data.error) {
22
+ data.data = result.response
23
+ }
24
+ return data
25
+ },
26
+ /**
27
+ * 查询热门交通数据
28
+ */
29
+ async trafficTop (http, serverName) {
30
+ let result = null
31
+ try {
32
+ result = await http.get(`${BASE_API}/v2/traffic/top?game=ets2&server=${serverName}`)
33
+ } catch {
34
+ return {
35
+ error: true
36
+ }
37
+ }
38
+
39
+ // 拼接返回数据
40
+ let data = {
41
+ error: !result || !result.response || result.response.length <= 0
42
+ }
43
+ if (!data.error) {
44
+ data.data = result.response
45
+ }
46
+ return data
47
+ }
48
+ }
@@ -0,0 +1,74 @@
1
+ module.exports = async (ctx, cfg, session, targetQQ) => {
2
+ const { url, token, logOutput } = cfg.mainSettings;
3
+ let queryQQ = targetQQ;
4
+ if (!queryQQ) {
5
+ queryQQ = session.userId;
6
+ } else {
7
+ if (queryQQ.startsWith("<at ")) {
8
+ if (queryQQ.startsWith('<at ')) {
9
+ queryQQ = queryQQ.replace('<at ', '');
10
+ }
11
+ let id = '';
12
+ const idStart = queryQQ.indexOf('id="');
13
+ if (idStart !== -1) {
14
+ const valueStart = idStart + 4;
15
+ const valueEnd = queryQQ.indexOf('"', valueStart);
16
+ if (valueEnd !== -1) {
17
+ id = queryQQ.substring(valueStart, valueEnd);
18
+ }
19
+ }
20
+ queryQQ = id;
21
+ }
22
+ if (!/^\d+$/.test(queryQQ)) {
23
+ return "QQ号格式不正确,请输入纯数字QQ号";
24
+ }
25
+ }
26
+ try {
27
+ if (logOutput) {
28
+ ctx.logger.info(`开始查询用户 ${queryQQ} 的积分`);
29
+ }
30
+ const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=&tmpName=&teamId=&qq=${queryQQ}&state=0&teamRole=`;
31
+ if (logOutput) {
32
+ ctx.logger.info(`请求用户信息: ${userInfoUrl}`);
33
+ }
34
+ const userInfoResponse = await ctx.http.post(userInfoUrl);
35
+ if (logOutput) {
36
+ ctx.logger.info(`用户信息响应: ${JSON.stringify(userInfoResponse)}`);
37
+ }
38
+ if (userInfoResponse.code !== 0) {
39
+ return `获取用户信息失败: ${userInfoResponse.msg || "未知错误"}`;
40
+ }
41
+ const userList = userInfoResponse.page?.list || [];
42
+ if (userList.length === 0) {
43
+ return `未找到QQ号 ${queryQQ} 关联的用户信息`;
44
+ }
45
+ const userInfo = userList[0];
46
+ const rewardPoints = userInfo.rewardPoints || 0;
47
+ const tmpName = userInfo.tmpName || "未知用户";
48
+ const teamRole = userInfo.teamRole || "未知职位";
49
+ const teamId = userInfo.teamId || "未知编号";
50
+ let message = `🚛 晚风车队平台 - 积分查询🚚
51
+ `;
52
+ message += `👤 用户: ${tmpName}
53
+ `;
54
+ message += `🆔 车队编号: ${teamId}
55
+ `;
56
+ message += `📧 QQ: ${queryQQ}
57
+ `;
58
+ message += `🏆 职位: ${teamRole}
59
+ `;
60
+ message += `⭐ 当前积分: ${rewardPoints}
61
+ `;
62
+ message += `📅 加入日期: ${userInfo.joinDate || "未知"}`;
63
+ return message;
64
+ } catch (error) {
65
+ ctx.logger.error(`积分查询过程出错: ${error}`);
66
+ if (error.response) {
67
+ return `请求失败: ${error.response.status} ${error.response.statusText}`;
68
+ } else if (error.code) {
69
+ return `网络错误: ${error.code}`;
70
+ } else {
71
+ return "系统错误,请稍后重试";
72
+ }
73
+ }
74
+ };
@@ -0,0 +1,174 @@
1
+ module.exports = async (ctx, cfg, session, targetTeamId) => {
2
+ const { url, token, logOutput } = cfg.mainSettings;
3
+ const { adminUsers } = cfg.resetPassword;
4
+ const currentUserQQ = session.userId;
5
+ const isAdmin = adminUsers.includes(currentUserQQ);
6
+ if (session.channelId !== `private:${session.userId}`) {
7
+ let qq = targetTeamId;
8
+ try {
9
+ if (!isAdmin) {
10
+ return "您没有权限重置其他用户的密码,请联系管理员重置";
11
+ }
12
+ if (qq.startsWith("<at ")) {
13
+ if (qq.startsWith('<at ')) {
14
+ qq = qq.replace('<at ', '');
15
+ }
16
+ let id = '';
17
+ const idStart = qq.indexOf('id="');
18
+ if (idStart !== -1) {
19
+ const valueStart = idStart + 4;
20
+ const valueEnd = qq.indexOf('"', valueStart);
21
+ if (valueEnd !== -1) {
22
+ id = qq.substring(valueStart, valueEnd);
23
+ }
24
+ }
25
+ queryQQ = id;
26
+ if (!/^\d+$/.test(queryQQ)) {
27
+ return "获取qq号错误,请使用车队编号重置";
28
+ }
29
+ if (logOutput) {
30
+ ctx.logger.info(`管理员 ${currentUserQQ} 请求重置 qq号 ${queryQQ} 的密码`);
31
+ }
32
+ const verifyUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=1&tmpId=&tmpName=&teamId=&qq=${queryQQ}&state=0&teamRole=`;
33
+ const verifyResponse = await ctx.http.post(verifyUrl);
34
+ if (verifyResponse.code !== 0 || !verifyResponse.page?.list?.length) {
35
+ return `未找到qq号为 ${queryQQ} 的用户信息`;
36
+ }
37
+ const userInfo = verifyResponse.page.list[0];
38
+ if (logOutput) {
39
+ ctx.logger.info(`目标用户信息: ${userInfo.tmpName} (QQ: ${userInfo.qq})`);
40
+ }
41
+ const teamId = userInfo.teamId;
42
+ const resetPasswordUrl = `https://${url}/api/user/info/resetPasswordWithTeamId?token=${token}&teamId=${teamId}`;
43
+ if (logOutput) {
44
+ ctx.logger.info(`请求重置密码: ${resetPasswordUrl}`);
45
+ }
46
+ const resetResponse = await ctx.http.post(resetPasswordUrl);
47
+ if (logOutput) {
48
+ ctx.logger.info(`重置密码响应: ${JSON.stringify(resetResponse)}`);
49
+ }
50
+ if (resetResponse.code === 0) {
51
+ if (targetTeamId) {
52
+ return `管理员操作:车队编号 ${teamId} 的密码重置成功!新密码已发送到用户邮箱。`;
53
+ } else {
54
+ return "密码重置成功!新密码已发送到您的邮箱,请查收。";
55
+ }
56
+ } else {
57
+ return `密码重置失败: ${resetResponse.msg || "未知错误"}`;
58
+ }
59
+ }
60
+ let teamId = qq;
61
+ if (logOutput) {
62
+ ctx.logger.info(`管理员 ${currentUserQQ} 请求重置 车队编号 ${teamId} 的密码`);
63
+ }
64
+ const verifyUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=1&tmpId=&tmpName=&teamId=${teamId}&qq=&state=0&teamRole=`;
65
+ const verifyResponse = await ctx.http.post(verifyUrl);
66
+ if (verifyResponse.code !== 0 || !verifyResponse.page?.list?.length) {
67
+ return `未找到车队编号为 ${teamId} 的用户信息`;
68
+ }
69
+ const userInfo = verifyResponse.page.list[0];
70
+ if (logOutput) {
71
+ ctx.logger.info(`目标用户信息: ${userInfo.tmpName} (QQ: ${userInfo.qq})`);
72
+ }
73
+ const resetPasswordUrl = `https://${url}/api/user/info/resetPasswordWithTeamId?token=${token}&teamId=${teamId}`;
74
+ if (logOutput) {
75
+ ctx.logger.info(`请求重置密码: ${resetPasswordUrl}`);
76
+ }
77
+ const resetResponse = await ctx.http.post(resetPasswordUrl);
78
+ if (logOutput) {
79
+ ctx.logger.info(`重置密码响应: ${JSON.stringify(resetResponse)}`);
80
+ }
81
+ if (resetResponse.code === 0) {
82
+ if (targetTeamId) {
83
+ return `管理员操作:车队编号 ${teamId} 的密码重置成功!新密码已发送到用户邮箱。`;
84
+ } else {
85
+ return "密码重置成功!新密码已发送到您的邮箱,请查收。";
86
+ }
87
+ } else {
88
+ return `密码重置失败: ${resetResponse.msg || "未知错误"}`;
89
+ }
90
+ } catch (error) {
91
+ ctx.logger.error(`密码重置过程出错: ${error}`);
92
+ if (error.response) {
93
+ return `请求失败: ${error.response.status} ${error.response.statusText}`;
94
+ } else if (error.code) {
95
+ return `网络错误: ${error.code}`;
96
+ } else {
97
+ return "系统错误,请稍后重试";
98
+ }
99
+ }
100
+ }
101
+ try {
102
+ let teamId;
103
+ if (!targetTeamId) {
104
+ if (logOutput) {
105
+ ctx.logger.info(`开始处理用户 ${currentUserQQ} 的密码重置请求`);
106
+ }
107
+ const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=&tmpName=&teamId=&qq=${currentUserQQ}&state=0&teamRole=`;
108
+ if (logOutput) {
109
+ ctx.logger.info(`请求用户信息: ${userInfoUrl}`);
110
+ }
111
+ const userInfoResponse = await ctx.http.post(userInfoUrl);
112
+ if (logOutput) {
113
+ ctx.logger.info(`用户信息响应: ${JSON.stringify(userInfoResponse)}`);
114
+ }
115
+ if (userInfoResponse.code !== 0) {
116
+ return `获取用户信息失败: ${userInfoResponse.msg || "未知错误"}`;
117
+ }
118
+ const userList = userInfoResponse.page?.list || [];
119
+ if (userList.length === 0) {
120
+ return "未找到与该QQ号关联的用户信息";
121
+ }
122
+ teamId = userList[0].teamId;
123
+ if (!teamId) {
124
+ return "在平台中未找到您的信息,请联系管理员重置密码";
125
+ }
126
+ if (logOutput) {
127
+ ctx.logger.info(`找到用户 车队编号: ${teamId}`);
128
+ }
129
+ } else {
130
+ if (!isAdmin) {
131
+ return "您没有权限重置其他成员的密码,请联系管理员";
132
+ }
133
+ teamId = targetTeamId;
134
+ if (logOutput) {
135
+ ctx.logger.info(`管理员 ${currentUserQQ} 请求重置 车队编号 ${teamId} 的密码`);
136
+ }
137
+ const verifyUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=1&tmpId=&tmpName=&teamId=${teamId}&qq=&state=0&teamRole=`;
138
+ const verifyResponse = await ctx.http.post(verifyUrl);
139
+ if (verifyResponse.code !== 0 || !verifyResponse.page?.list?.length) {
140
+ return `未找到车队编号为 ${teamId} 的用户信息`;
141
+ }
142
+ const userInfo = verifyResponse.page.list[0];
143
+ if (logOutput) {
144
+ ctx.logger.info(`目标用户信息: ${userInfo.tmpName} (QQ: ${userInfo.qq})`);
145
+ }
146
+ }
147
+ const resetPasswordUrl = `https://${url}/api/user/info/resetPasswordWithTeamId?token=${token}&teamId=${teamId}`;
148
+ if (logOutput) {
149
+ ctx.logger.info(`请求重置密码: ${resetPasswordUrl}`);
150
+ }
151
+ const resetResponse = await ctx.http.post(resetPasswordUrl);
152
+ if (logOutput) {
153
+ ctx.logger.info(`重置密码响应: ${JSON.stringify(resetResponse)}`);
154
+ }
155
+ if (resetResponse.code === 0) {
156
+ if (targetTeamId) {
157
+ return `管理员操作:车队编号 ${teamId} 的密码重置成功!新密码已发送到用户邮箱。`;
158
+ } else {
159
+ return "密码重置成功!新密码已发送到您的邮箱,请查收。";
160
+ }
161
+ } else {
162
+ return `密码重置失败: ${resetResponse.msg || "未知错误"}`;
163
+ }
164
+ } catch (error) {
165
+ ctx.logger.error(`密码重置过程出错: ${error}`);
166
+ if (error.response) {
167
+ return `请求失败: ${error.response.status} ${error.response.statusText}`;
168
+ } else if (error.code) {
169
+ return `网络错误: ${error.code}`;
170
+ } else {
171
+ return "系统错误,请稍后重试";
172
+ }
173
+ }
174
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(ctx: any, cfg: any, session: any, tmpId: any): Promise<string>;
2
+ export = _exports;
@@ -0,0 +1,18 @@
1
+ const guildBind = require('../database/guildBind');
2
+ const truckersMpApi = require("../api/truckersMpApi");
3
+ /**
4
+ * 绑定 TMP ID
5
+ */
6
+ module.exports = async (ctx, cfg, session, tmpId) => {
7
+ if (!tmpId || isNaN(tmpId)) {
8
+ return `请输入正确的玩家编号`;
9
+ }
10
+ // 查询玩家信息
11
+ let playerInfo = await truckersMpApi.player(ctx.http, tmpId);
12
+ if (playerInfo.error) {
13
+ return '绑定失败 (查询玩家信息失败)';
14
+ }
15
+ // 更新数据库
16
+ guildBind.saveOrUpdate(ctx.database, session.platform, session.userId, tmpId);
17
+ return `绑定成功 ( ${playerInfo.data.name} )`;
18
+ };
@@ -0,0 +1,3 @@
1
+ declare function _exports(ctx: any, session: any): Promise<segment | "未启用 Puppeteer 功能" | "渲染异常,请重试">;
2
+ export = _exports;
3
+ import { segment } from "@koishijs/core";