koishi-plugin-ets2-tools-tmp 2.2.0 → 2.2.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.
@@ -1,8 +1,6 @@
1
1
  module.exports = async (ctx, cfg, session, targetQQ) => {
2
- const { url, token, logOutput, platformVersion } = cfg.mainSettings?.settings || {};
3
- if ((platformVersion || "v1").toLowerCase() === "v2") {
4
- return "车队平台V2.0暂不支持积分查询";
5
- }
2
+ const { Name, url, token, logOutput, platformVersion } = cfg.mainSettings?.settings || {};
3
+ const platform = (platformVersion || "v1").toLowerCase();
6
4
  let queryQQ = targetQQ;
7
5
  if (!queryQQ) {
8
6
  queryQQ = session.userId;
@@ -30,27 +28,48 @@ module.exports = async (ctx, cfg, session, targetQQ) => {
30
28
  if (logOutput) {
31
29
  ctx.logger.info(`开始查询用户 ${queryQQ} 的积分`);
32
30
  }
33
- const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=&tmpName=&teamId=&qq=${queryQQ}&state=0&teamRole=`;
34
- if (logOutput) {
35
- ctx.logger.info(`请求用户信息: ${userInfoUrl}`);
36
- }
37
- const userInfoResponse = await ctx.http.post(userInfoUrl);
38
- if (logOutput) {
39
- ctx.logger.info(`用户信息响应: ${JSON.stringify(userInfoResponse)}`);
40
- }
41
- if (userInfoResponse.code !== 0) {
42
- return `获取用户信息失败: ${userInfoResponse.msg || "未知错误"}`;
43
- }
44
- const userList = userInfoResponse.page?.list || [];
45
- if (userList.length === 0) {
46
- return `未找到QQ号 ${queryQQ} 关联的用户信息`;
31
+ let userInfo;
32
+ if (platform === "v2") {
33
+ const baseUrl = url || "open.vtcm.link";
34
+ const userInfoUrl = `https://${baseUrl}/members/get?token=${token}&qq=${queryQQ}`;
35
+ if (logOutput) {
36
+ ctx.logger.info(`请求V2.0用户信息: ${userInfoUrl}`);
37
+ }
38
+ const userInfoResponse = await ctx.http.get(userInfoUrl);
39
+ if (logOutput) {
40
+ ctx.logger.info(`V2.0用户信息响应: ${JSON.stringify(userInfoResponse)}`);
41
+ }
42
+ if (userInfoResponse.code !== 200) {
43
+ return `获取用户信息失败: ${userInfoResponse.msg || "未知错误"}`;
44
+ }
45
+ if (!userInfoResponse.data) {
46
+ return `未找到QQ号 ${queryQQ} 关联的用户信息`;
47
+ }
48
+ userInfo = userInfoResponse.data;
49
+ } else {
50
+ const userInfoUrl = `https://${url}/api/user/info/list?token=${token}&page=0&limit=7&tmpId=&tmpName=&teamId=&qq=${queryQQ}&state=0&teamRole=`;
51
+ if (logOutput) {
52
+ ctx.logger.info(`请求V1.0用户信息: ${userInfoUrl}`);
53
+ }
54
+ const userInfoResponse = await ctx.http.post(userInfoUrl);
55
+ if (logOutput) {
56
+ ctx.logger.info(`V1.0用户信息响应: ${JSON.stringify(userInfoResponse)}`);
57
+ }
58
+ if (userInfoResponse.code !== 0) {
59
+ return `获取用户信息失败: ${userInfoResponse.msg || "未知错误"}`;
60
+ }
61
+ const userList = userInfoResponse.page?.list || [];
62
+ if (userList.length === 0) {
63
+ return `未找到QQ号 ${queryQQ} 关联的用户信息`;
64
+ }
65
+ userInfo = userList[0];
47
66
  }
48
- const userInfo = userList[0];
49
- const rewardPoints = userInfo.rewardPoints || 0;
50
67
  const tmpName = userInfo.tmpName || "未知用户";
51
- const teamRole = userInfo.teamRole || "未知职位";
52
- const teamId = userInfo.teamId || "未知编号";
53
- let message = `🚛 晚风车队平台 - 积分查询🚚
68
+ const teamRole = userInfo.teamRole || userInfo.tmpRole || "未知职位";
69
+ const teamId = userInfo.teamId || userInfo.uid || "未知编号";
70
+ const rewardPoints = userInfo.rewardPoints || userInfo.point || 0;
71
+ const joinDate = userInfo.joinDate || "未知";
72
+ let message = `🚛 ${Name}平台 - 积分查询🚚
54
73
  `;
55
74
  message += `👤 用户: ${tmpName}
56
75
  `;
@@ -62,7 +81,7 @@ module.exports = async (ctx, cfg, session, targetQQ) => {
62
81
  `;
63
82
  message += `⭐ 当前积分: ${rewardPoints}
64
83
  `;
65
- message += `📅 加入日期: ${userInfo.joinDate || "未知"}`;
84
+ message += `📅 加入日期: ${joinDate}`;
66
85
  return message;
67
86
  } catch (error) {
68
87
  ctx.logger.error(`积分查询过程出错: ${error}`);
package/lib/index.js CHANGED
@@ -99,6 +99,7 @@ exports.Config = koishi_1.Schema.intersect([
99
99
  }).description('路况查询配置'),
100
100
  mainSettings: koishi_1.Schema.object({
101
101
  settings: koishi_1.Schema.object({
102
+ Name: koishi_1.Schema.string().description("车队名称"),
102
103
  platformVersion: koishi_1.Schema.union([
103
104
  koishi_1.Schema.const("v1").description("车队平台V1.0"),
104
105
  koishi_1.Schema.const("v2").description("车队平台V2.0")
@@ -111,7 +112,7 @@ exports.Config = koishi_1.Schema.intersect([
111
112
  mailTemplate: koishi_1.Schema.string().description("V2.0重置密码邮件内容模板,支持变量:{uid} {qq} {password} {psw}").default("我们已将您平台的密码进行重置,您的账号:{uid},新的密码为:{psw} 请妥善保管好您的密码,以防泄露"),
112
113
  mailFromName: koishi_1.Schema.string().description("V2.0重置密码邮件发件人名字(覆盖 adapter-mail 的 name)").default(""),
113
114
  logOutput: koishi_1.Schema.boolean().description("是否输出日志").default(true)
114
- }).description("V1/V2通用配置")
115
+ }).description("通用配置")
115
116
  }).description("车队平台配置"),
116
117
  resetPassword: koishi_1.Schema.object({
117
118
  settings: koishi_1.Schema.object({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ets2-tools-tmp",
3
3
  "description": "欧卡2 TMP在线查询、车队平台查询及活动提醒",
4
- "version": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>",
7
7
  "bot_actions <168329908@qq.com>"