koishi-plugin-ets2-tools-tmp 2.4.0 → 2.4.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.
@@ -74,52 +74,54 @@ module.exports = async (ctx, cfg, session, tmpId) => {
74
74
  message += '\n💼所属分组: ' + (userGroup[playerInfo.data.groupName] || playerInfo.data.groupName);
75
75
  if (playerInfo.data.isJoinVtc) {
76
76
  message += '\n🚚所属车队: ' + playerInfo.data.vtcName;
77
- if(cfg.commands?.tmpQueryHistory){
77
+ if (cfg.commands?.tmpQueryHistory) {
78
78
  if (playerInfo.data.vtcHistory && playerInfo.data.vtcHistory.length > 0) {
79
79
  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')}`
80
80
  }
81
81
  }
82
82
  message += '\n🚚车队角色: ' + playerInfo.data.vtcRole;
83
- if (playerInfo.data.vtcId == vtcId) {
84
- const { url, token, logOutput, platformVersion } = cfg.mainSettings?.settings || {};
85
- const platform = (platformVersion || "v1").toLowerCase();
86
- try {
87
- let rewardPoints = 0;
88
- if (platform === "v2") {
89
- const baseUrl = url;
90
- const userInfoUrl = `https://${baseUrl}/members/get?token=${token}&tmpId=${tmpId}`;
91
- if (logOutput) {
92
- ctx.logger.info(`[TMP_BOT] tmpQuery:开始查询TmpID ${tmpId} 的V2.0积分`);
93
- ctx.logger.info(`[TMP_BOT] 请求V2.0用户信息: ${userInfoUrl}`);
83
+ if (cfg.commands?.mainSettings) {
84
+ if (playerInfo.data.vtcId == vtcId) {
85
+ const { url, token, logOutput, platformVersion } = cfg.mainSettings?.settings || {};
86
+ const platform = (platformVersion || "v1").toLowerCase();
87
+ try {
88
+ let rewardPoints = 0;
89
+ if (platform === "v2") {
90
+ const baseUrl = url;
91
+ const userInfoUrl = `https://${baseUrl}/members/get?token=${token}&tmpId=${tmpId}`;
92
+ if (logOutput) {
93
+ ctx.logger.info(`[TMP_BOT] tmpQuery:开始查询TmpID ${tmpId} 的V2.0积分`);
94
+ ctx.logger.info(`[TMP_BOT] 请求V2.0用户信息: ${userInfoUrl}`);
95
+ }
96
+ const userInfoResponse = await ctx.http.get(userInfoUrl);
97
+ if (logOutput) {
98
+ ctx.logger.info(`[TMP_BOT] V2.0用户信息响应: ${JSON.stringify(userInfoResponse)}`);
99
+ }
100
+ if (userInfoResponse.code === 200 && userInfoResponse.data) {
101
+ rewardPoints = userInfoResponse.data.point || 0;
102
+ }
103
+ } else {
104
+ if (logOutput) {
105
+ ctx.logger.info(`[TMP_BOT] tmpQuery:开始查询TmpID ${tmpId} 的V1.0积分`);
106
+ }
107
+ const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=${tmpId}&tmpName=&teamId=&qq=&state=0&teamRole=`;
108
+ if (logOutput) {
109
+ ctx.logger.info(`[TMP_BOT] 请求V1.0用户信息: ${userInfoUrl}`);
110
+ }
111
+ const userInfoResponse = await ctx.http.post(userInfoUrl);
112
+ if (logOutput) {
113
+ ctx.logger.info(`[TMP_BOT] V1.0用户信息响应: ${JSON.stringify(userInfoResponse)}`);
114
+ }
115
+ const userList = userInfoResponse.page?.list || [];
116
+ const userInfo = userList[0];
117
+ rewardPoints = userInfo.rewardPoints || 0;
94
118
  }
95
- const userInfoResponse = await ctx.http.get(userInfoUrl);
96
- if (logOutput) {
97
- ctx.logger.info(`[TMP_BOT] V2.0用户信息响应: ${JSON.stringify(userInfoResponse)}`);
119
+ message += `\n⭐ 当前车队积分: ${rewardPoints}`;
120
+ } catch (error) {
121
+ ctx.logger.error(`积分查询过程出错: ${error}`);
122
+ if (error.response) {
123
+ message += '查询出错';
98
124
  }
99
- if (userInfoResponse.code === 200 && userInfoResponse.data) {
100
- rewardPoints = userInfoResponse.data.point || 0;
101
- }
102
- } else {
103
- if (logOutput) {
104
- ctx.logger.info(`[TMP_BOT] tmpQuery:开始查询TmpID ${tmpId} 的V1.0积分`);
105
- }
106
- const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=${tmpId}&tmpName=&teamId=&qq=&state=0&teamRole=`;
107
- if (logOutput) {
108
- ctx.logger.info(`[TMP_BOT] 请求V1.0用户信息: ${userInfoUrl}`);
109
- }
110
- const userInfoResponse = await ctx.http.post(userInfoUrl);
111
- if (logOutput) {
112
- ctx.logger.info(`[TMP_BOT] V1.0用户信息响应: ${JSON.stringify(userInfoResponse)}`);
113
- }
114
- const userList = userInfoResponse.page?.list || [];
115
- const userInfo = userList[0];
116
- rewardPoints = userInfo.rewardPoints || 0;
117
- }
118
- message += `\n⭐ 当前车队积分: ${rewardPoints}`;
119
- } catch (error) {
120
- ctx.logger.error(`积分查询过程出错: ${error}`);
121
- if (error.response) {
122
- message += '查询出错';
123
125
  }
124
126
  }
125
127
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ets2-tools-tmp",
3
3
  "description": "欧卡2 TruckersMP信息查询、车队平台查询及活动提醒",
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>",
7
7
  "bot_actions <168329908@qq.com>"