koishi-plugin-bind-bot 2.2.9 → 2.4.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.
@@ -38,6 +38,7 @@ const XLSX = __importStar(require("xlsx"));
38
38
  const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
40
  const bind_status_1 = require("./utils/bind-status");
41
+ const helpers_1 = require("./utils/helpers");
41
42
  class GroupExporter {
42
43
  logger;
43
44
  ctx;
@@ -169,7 +170,7 @@ class GroupExporter {
169
170
  MC_UUID: binding?.mcUuid || '',
170
171
  B站UID: binding?.buidUid || '',
171
172
  B站用户名: binding?.buidUsername || '',
172
- 舰长等级: binding?.guardLevelText || '',
173
+ 舰长等级: (0, helpers_1.getGuardLevelText)(binding?.guardLevel),
173
174
  粉丝牌名称: binding?.medalName || '',
174
175
  粉丝牌等级: binding?.medalLevel ? binding.medalLevel.toString() : '',
175
176
  荣耀等级: binding?.wealthMedalLevel ? binding.wealthMedalLevel.toString() : '',
@@ -17,10 +17,6 @@ export declare class ForceBinder {
17
17
  * 获取用户的粉丝勋章信息(使用B站API)
18
18
  */
19
19
  private getBilibiliMedals;
20
- /**
21
- * 获取用户的基本信息(使用ZMINFO API)
22
- */
23
- private getZminfoUserInfo;
24
20
  /**
25
21
  * 检查是否拥有目标粉丝牌
26
22
  */
@@ -103,32 +103,6 @@ class ForceBinder {
103
103
  throw error;
104
104
  }
105
105
  }
106
- /**
107
- * 获取用户的基本信息(使用ZMINFO API)
108
- */
109
- async getZminfoUserInfo(uid) {
110
- this.logger.debug('强制绑定', `开始获取用户 ${uid} 的ZMINFO信息`);
111
- try {
112
- const response = await axios_1.default.get(`${this.config.zminfoApiUrl}/api/user/${uid}`, {
113
- timeout: 10000,
114
- headers: {
115
- 'User-Agent': 'Koishi-MCID-Bot/1.0'
116
- }
117
- });
118
- if (response.data.success && response.data.data && response.data.data.user) {
119
- this.logger.debug('强制绑定', `ZMINFO API 用户信息获取成功: ${response.data.data.user.username}`);
120
- return response.data.data.user;
121
- }
122
- else {
123
- this.logger.warn('强制绑定', `ZMINFO API 返回失败: ${response.data.message}`);
124
- return null;
125
- }
126
- }
127
- catch (error) {
128
- this.logger.error('强制绑定', '获取ZMINFO用户信息失败', error);
129
- throw new Error(`无法获取用户信息: ${error.message}`);
130
- }
131
- }
132
106
  /**
133
107
  * 检查是否拥有目标粉丝牌
134
108
  */
@@ -4,6 +4,7 @@ exports.BindingHandler = void 0;
4
4
  const koishi_1 = require("koishi");
5
5
  const base_handler_1 = require("./base.handler");
6
6
  const bind_status_1 = require("../utils/bind-status");
7
+ const helpers_1 = require("../utils/helpers");
7
8
  /**
8
9
  * 交互式绑定命令处理器
9
10
  * 处理 "绑定" 命令,引导用户完成 MC 和 B站双重绑定
@@ -25,7 +26,7 @@ class BindingHandler extends base_handler_1.BaseHandler {
25
26
  const displayUsername = bind_status_1.BindStatus.getDisplayMcUsername(bind, '未绑定');
26
27
  let bindInfo = `${prefix}\n✅ MC账号: ${displayUsername}\n✅ B站账号: ${bind.buidUsername} (UID: ${bind.buidUid})`;
27
28
  if (bind.guardLevel > 0) {
28
- bindInfo += `\n舰长等级: ${bind.guardLevelText}`;
29
+ bindInfo += `\n舰长等级: ${(0, helpers_1.getGuardLevelText)(bind.guardLevel)}`;
29
30
  }
30
31
  if (bind.medalName) {
31
32
  bindInfo += `\n粉丝牌: ${bind.medalName} Lv.${bind.medalLevel}`;
@@ -37,7 +37,7 @@ export declare class BuidHandler extends BaseHandler {
37
37
  */
38
38
  private parseUidInput;
39
39
  /**
40
- * 验证B站UID
40
+ * 验证B站UID(通过Supabase events表查询)
41
41
  */
42
42
  private validateBUID;
43
43
  /**
@@ -46,12 +46,9 @@ export declare class BuidHandler extends BaseHandler {
46
46
  private checkBuidExists;
47
47
  /**
48
48
  * 创建或更新B站账号绑定
49
+ * 只写入 buidUid 和 buidUsername,详细字段由数据库触发器填充
49
50
  */
50
51
  private createOrUpdateBuidBind;
51
- /**
52
- * 仅更新B站信息,不更新绑定时间
53
- */
54
- private updateBuidInfoOnly;
55
52
  /**
56
53
  * 检查是否为管理员
57
54
  */
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.BuidHandler = void 0;
7
4
  const koishi_1 = require("koishi");
8
5
  const base_handler_1 = require("./base.handler");
9
- const axios_1 = __importDefault(require("axios"));
10
6
  const bind_status_1 = require("../utils/bind-status");
7
+ const helpers_1 = require("../utils/helpers");
11
8
  /**
12
9
  * BUID 命令处理器
13
10
  * 处理 B站账号相关命令
@@ -65,26 +62,17 @@ class BuidHandler extends base_handler_1.BaseHandler {
65
62
  : `您尚未绑定B站账号,请使用 ${this.deps.formatCommand('buid bind <UID>')} 进行绑定`)
66
63
  ]);
67
64
  }
68
- // 每次查询都必须从API获取最新数据
69
- const buidUser = await this.validateBUID(bind.buidUid);
70
- if (!buidUser) {
71
- return this.deps.sendMessage(session, [
72
- koishi_1.h.text(`无法从API获取B站UID ${bind.buidUid} 的最新数据,该用户可能不存在或API服务暂时不可用`)
73
- ]);
74
- }
75
- // 更新本地数据库中的信息
76
- await this.updateBuidInfoOnly(bind.qqId, buidUser);
77
- bind = await this.repos.mcidbind.findByQQId(bind.qqId);
65
+ // 直接从数据库读取(数据由触发器自动刷新)
78
66
  const userInfo = `${target ? `用户 ${bind.qqId} 的` : '您的'}B站账号信息:\nB站UID: ${bind.buidUid}\n用户名: ${bind.buidUsername}`;
79
67
  let detailInfo = '';
80
68
  if (bind.guardLevel > 0) {
81
- detailInfo += `\n舰长等级: ${bind.guardLevelText} (${bind.guardLevel})`;
69
+ detailInfo += `\n舰长等级: ${(0, helpers_1.getGuardLevelText)(bind.guardLevel)} (${bind.guardLevel})`;
82
70
  if (bind.maxGuardLevel > 0 && bind.maxGuardLevel < bind.guardLevel) {
83
- detailInfo += `\n历史最高: ${bind.maxGuardLevelText} (${bind.maxGuardLevel})`;
71
+ detailInfo += `\n历史最高: ${(0, helpers_1.getGuardLevelText)(bind.maxGuardLevel)} (${bind.maxGuardLevel})`;
84
72
  }
85
73
  }
86
74
  else if (bind.maxGuardLevel > 0) {
87
- detailInfo += `\n历史舰长: ${bind.maxGuardLevelText} (${bind.maxGuardLevel})`;
75
+ detailInfo += `\n历史舰长: ${(0, helpers_1.getGuardLevelText)(bind.maxGuardLevel)} (${bind.maxGuardLevel})`;
88
76
  }
89
77
  detailInfo += `\n粉丝牌: ${bind.medalName || '无'} Lv.${bind.medalLevel || 0}`;
90
78
  detailInfo += `\n荣耀等级: ${bind.wealthMedalLevel || 0}`;
@@ -161,13 +149,13 @@ class BuidHandler extends base_handler_1.BaseHandler {
161
149
  // 构建详细信息
162
150
  let adminInfo = `B站UID"${bind.buidUid}"绑定信息:\nQQ号: ${bind.qqId}\n用户名: ${bind.buidUsername}`;
163
151
  if (bind.guardLevel > 0) {
164
- adminInfo += `\n舰长等级: ${bind.guardLevelText} (${bind.guardLevel})`;
152
+ adminInfo += `\n舰长等级: ${(0, helpers_1.getGuardLevelText)(bind.guardLevel)} (${bind.guardLevel})`;
165
153
  if (bind.maxGuardLevel > 0 && bind.maxGuardLevel < bind.guardLevel) {
166
- adminInfo += `\n历史最高: ${bind.maxGuardLevelText} (${bind.maxGuardLevel})`;
154
+ adminInfo += `\n历史最高: ${(0, helpers_1.getGuardLevelText)(bind.maxGuardLevel)} (${bind.maxGuardLevel})`;
167
155
  }
168
156
  }
169
157
  else if (bind.maxGuardLevel > 0) {
170
- adminInfo += `\n历史舰长: ${bind.maxGuardLevelText} (${bind.maxGuardLevel})`;
158
+ adminInfo += `\n历史舰长: ${(0, helpers_1.getGuardLevelText)(bind.maxGuardLevel)} (${bind.maxGuardLevel})`;
171
159
  }
172
160
  if (bind.medalName) {
173
161
  adminInfo += `\n粉丝牌: ${bind.medalName} Lv.${bind.medalLevel}`;
@@ -300,39 +288,10 @@ class BuidHandler extends base_handler_1.BaseHandler {
300
288
  return actualUid;
301
289
  }
302
290
  /**
303
- * 验证B站UID
291
+ * 验证B站UID(通过Supabase events表查询)
304
292
  */
305
293
  async validateBUID(buid) {
306
- try {
307
- if (!buid || !/^\d+$/.test(buid)) {
308
- this.logger.warn('B站账号验证', `无效的B站UID格式: ${buid}`);
309
- return null;
310
- }
311
- this.logger.debug('B站账号验证', `验证B站UID: ${buid}`);
312
- const response = await axios_1.default.get(`${this.config.zminfoApiUrl}/api/user/${buid}`, {
313
- timeout: 10000,
314
- headers: {
315
- 'User-Agent': 'Koishi-MCID-Bot/1.0'
316
- }
317
- });
318
- if (response.data.success && response.data.data && response.data.data.user) {
319
- const user = response.data.data.user;
320
- this.logger.debug('B站账号验证', `B站UID ${buid} 验证成功: ${user.username}`);
321
- return user;
322
- }
323
- else {
324
- this.logger.warn('B站账号验证', `B站UID ${buid} 不存在或API返回失败: ${response.data.message}`);
325
- return null;
326
- }
327
- }
328
- catch (error) {
329
- if (error.response?.status === 404) {
330
- this.logger.warn('B站账号验证', `B站UID ${buid} 不存在`);
331
- return null;
332
- }
333
- this.logger.error('B站账号验证', 'system', `验证B站UID ${buid} 时出错: ${error.message}`);
334
- throw new Error(`无法验证B站UID: ${error.message}`);
335
- }
294
+ return this.repos.mcidbind.validateBuidUid(buid);
336
295
  }
337
296
  /**
338
297
  * 检查B站UID是否已被其他用户绑定
@@ -355,6 +314,7 @@ class BuidHandler extends base_handler_1.BaseHandler {
355
314
  }
356
315
  /**
357
316
  * 创建或更新B站账号绑定
317
+ * 只写入 buidUid 和 buidUsername,详细字段由数据库触发器填充
358
318
  */
359
319
  async createOrUpdateBuidBind(userId, buidUser) {
360
320
  try {
@@ -373,16 +333,6 @@ class BuidHandler extends base_handler_1.BaseHandler {
373
333
  const updateData = {
374
334
  buidUid: buidUser.uid,
375
335
  buidUsername: buidUser.username,
376
- guardLevel: buidUser.guard_level || 0,
377
- guardLevelText: buidUser.guard_level_text || '',
378
- maxGuardLevel: buidUser.max_guard_level || 0,
379
- maxGuardLevelText: buidUser.max_guard_level_text || '',
380
- medalName: buidUser.medal?.name || '',
381
- medalLevel: buidUser.medal?.level || 0,
382
- wealthMedalLevel: buidUser.wealthMedalLevel || 0,
383
- lastActiveTime: buidUser.last_active_time
384
- ? new Date(buidUser.last_active_time)
385
- : new Date(),
386
336
  lastModified: new Date()
387
337
  };
388
338
  if (bind) {
@@ -413,41 +363,6 @@ class BuidHandler extends base_handler_1.BaseHandler {
413
363
  return false;
414
364
  }
415
365
  }
416
- /**
417
- * 仅更新B站信息,不更新绑定时间
418
- */
419
- async updateBuidInfoOnly(userId, buidUser) {
420
- try {
421
- const normalizedQQId = this.deps.normalizeQQId(userId);
422
- if (!normalizedQQId) {
423
- this.logger.error('B站账号信息更新', 'system', '更新失败: 无法提取有效的QQ号');
424
- return false;
425
- }
426
- const bind = await this.repos.mcidbind.findByQQId(normalizedQQId);
427
- if (!bind) {
428
- this.logger.warn('B站账号信息更新', `QQ(${normalizedQQId})没有绑定记录,无法更新B站信息`);
429
- return false;
430
- }
431
- const updateData = {
432
- buidUsername: buidUser.username,
433
- guardLevel: buidUser.guard_level || 0,
434
- guardLevelText: buidUser.guard_level_text || '',
435
- maxGuardLevel: buidUser.max_guard_level || 0,
436
- maxGuardLevelText: buidUser.max_guard_level_text || '',
437
- medalName: buidUser.medal?.name || '',
438
- medalLevel: buidUser.medal?.level || 0,
439
- wealthMedalLevel: buidUser.wealthMedalLevel || 0,
440
- lastActiveTime: buidUser.last_active_time ? new Date(buidUser.last_active_time) : new Date()
441
- };
442
- await this.repos.mcidbind.update(normalizedQQId, updateData);
443
- this.logger.info('B站账号信息更新', `刷新信息: QQ=${normalizedQQId}, B站UID=${bind.buidUid}, 用户名=${buidUser.username}`);
444
- return true;
445
- }
446
- catch (error) {
447
- this.logger.error('B站账号信息更新', userId, `更新B站账号信息失败: ${error.message}`);
448
- return false;
449
- }
450
- }
451
366
  /**
452
367
  * 检查是否为管理员
453
368
  */
@@ -641,7 +556,7 @@ class BuidHandler extends base_handler_1.BaseHandler {
641
556
  this.logger.warn('绑定', `管理员QQ(${operatorQQId})为QQ(${normalizedTargetId})B站绑定后群昵称设置失败: ${renameError.message}`);
642
557
  }
643
558
  return this.deps.sendMessage(session, [
644
- koishi_1.h.text(`已成功为用户 ${normalizedTargetId} 绑定B站账号\n用户名: ${buidUser.username}\nUID: ${actualUid}\n${buidUser.guard_level > 0 ? `舰长等级: ${buidUser.guard_level_text}\n` : ''}${buidUser.medal ? `粉丝牌: ${buidUser.medal.name} Lv.${buidUser.medal.level}` : ''}`)
559
+ koishi_1.h.text(`已成功为用户 ${normalizedTargetId} 绑定B站账号\n用户名: ${buidUser.username}\nUID: ${actualUid}`)
645
560
  ]);
646
561
  }
647
562
  /**
@@ -705,13 +620,6 @@ class BuidHandler extends base_handler_1.BaseHandler {
705
620
  koishi_1.h.text('成功绑定B站账号!\n'),
706
621
  koishi_1.h.text(`B站UID: ${buidUser.uid}\n`),
707
622
  koishi_1.h.text(`用户名: ${buidUser.username}\n`),
708
- buidUser.guard_level > 0
709
- ? koishi_1.h.text(`舰长等级: ${buidUser.guard_level_text} (${buidUser.guard_level})\n`)
710
- : null,
711
- buidUser.medal
712
- ? koishi_1.h.text(`粉丝牌: ${buidUser.medal.name} Lv.${buidUser.medal.level}\n`)
713
- : null,
714
- buidUser.wealthMedalLevel > 0 ? koishi_1.h.text(`荣耀等级: ${buidUser.wealthMedalLevel}\n`) : null,
715
623
  ...(this.config?.showAvatar
716
624
  ? [koishi_1.h.image(`https://workers.vrp.moe/bilibili/avatar/${buidUser.uid}?size=160`)]
717
625
  : [])
@@ -197,22 +197,22 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
197
197
  this.logger.debug('入群审批', `✅ 强制绑定模式获取成功: ${buidUsername}, 目标粉丝牌: ${targetMedalInfo?.found ? '已找到' : '未找到'}`);
198
198
  }
199
199
  catch (error) {
200
- this.logger.warn('入群审批', `强制绑定获取用户信息失败: ${error.message},降级到ZMINFO`);
201
- // 降级:使用ZMINFO
202
- zminfoData = await this.deps.apiService.validateBUID(parsedUid).catch(() => null);
203
- if (zminfoData) {
204
- buidUsername = zminfoData.username;
205
- this.logger.debug('入群审批', `⚠️ 降级到ZMINFO用户名: ${buidUsername}`);
200
+ this.logger.warn('入群审批', `强制绑定获取用户信息失败: ${error.message},降级到数据库查询`);
201
+ // 降级:使用Supabase events表查询
202
+ const dbResult = await this.repos.mcidbind.validateBuidUid(parsedUid).catch(() => null);
203
+ if (dbResult) {
204
+ buidUsername = dbResult.username;
205
+ this.logger.debug('入群审批', `⚠️ 降级到数据库查询用户名: ${buidUsername}`);
206
206
  }
207
207
  }
208
208
  }
209
209
  else {
210
- // 未配置Cookie,直接使用ZMINFO
211
- this.logger.debug('入群审批', '未配置强制绑定Cookie,使用ZMINFO获取用户信息...');
212
- zminfoData = await this.deps.apiService.validateBUID(parsedUid).catch(() => null);
213
- if (zminfoData) {
214
- buidUsername = zminfoData.username;
215
- this.logger.debug('入群审批', `✅ ZMINFO用户名: ${buidUsername}`);
210
+ // 未配置Cookie,使用Supabase events表查询
211
+ this.logger.debug('入群审批', '未配置强制绑定Cookie,使用数据库查询用户信息...');
212
+ const dbResult = await this.repos.mcidbind.validateBuidUid(parsedUid).catch(() => null);
213
+ if (dbResult) {
214
+ buidUsername = dbResult.username;
215
+ this.logger.debug('入群审批', `✅ 数据库查询用户名: ${buidUsername}`);
216
216
  }
217
217
  }
218
218
  // 粉丝牌信息:优先使用强制绑定获取的目标粉丝牌,其次使用ZMINFO的当前佩戴粉丝牌
@@ -638,9 +638,7 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
638
638
  buidUid: zminfoUser.uid,
639
639
  buidUsername: zminfoUser.username,
640
640
  guardLevel: zminfoUser.guard_level || 0,
641
- guardLevelText: zminfoUser.guard_level_text || '',
642
641
  maxGuardLevel: zminfoUser.guard_level || 0,
643
- maxGuardLevelText: zminfoUser.guard_level_text || '',
644
642
  medalName: zminfoUser.medal?.name || '',
645
643
  medalLevel: zminfoUser.medal?.level || 0,
646
644
  wealthMedalLevel: zminfoUser.wealthMedalLevel || 0,
@@ -659,11 +657,7 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
659
657
  buidUid: zminfoUser.uid,
660
658
  buidUsername: zminfoUser.username,
661
659
  guardLevel: zminfoUser.guard_level || 0,
662
- guardLevelText: zminfoUser.guard_level_text || '',
663
660
  maxGuardLevel: Math.max(bind.maxGuardLevel || 0, zminfoUser.guard_level || 0),
664
- maxGuardLevelText: zminfoUser.guard_level > (bind.maxGuardLevel || 0)
665
- ? zminfoUser.guard_level_text
666
- : bind.maxGuardLevelText,
667
661
  medalName: zminfoUser.medal?.name || '',
668
662
  medalLevel: zminfoUser.medal?.level || 0,
669
663
  wealthMedalLevel: zminfoUser.wealthMedalLevel || 0,
@@ -4,6 +4,7 @@ exports.McidCommandHandler = void 0;
4
4
  const koishi_1 = require("koishi");
5
5
  const base_handler_1 = require("./base.handler");
6
6
  const bind_status_1 = require("../utils/bind-status");
7
+ const helpers_1 = require("../utils/helpers");
7
8
  class McidCommandHandler extends base_handler_1.BaseHandler {
8
9
  /**
9
10
  * 注册所有MCID命令
@@ -83,34 +84,27 @@ class McidCommandHandler extends base_handler_1.BaseHandler {
83
84
  const targetBind = await this.deps.databaseService.getMcBindByQQId(normalizedTargetId);
84
85
  if (!targetBind || !bind_status_1.BindStatus.hasValidMcBind(targetBind)) {
85
86
  this.logger.info('查询', `QQ(${normalizedTargetId})未绑定MC账号`);
86
- // 检查是否绑定了B
87
+ // 检查是否绑定了B站(直接从数据库读取,数据由触发器自动刷新)
87
88
  if (targetBind && targetBind.buidUid) {
88
- const buidUser = await this.deps.apiService.validateBUID(targetBind.buidUid);
89
- if (buidUser) {
90
- await this.deps.databaseService.updateBuidInfoOnly(targetBind.qqId, buidUser);
91
- const refreshedBind = await this.deps.databaseService.getMcBindByQQId(normalizedTargetId);
92
- if (refreshedBind) {
93
- let buidInfo = `该用户尚未绑定MC账号\n\nB站账号信息:\nB站UID: ${refreshedBind.buidUid}\n用户名: ${refreshedBind.buidUsername}`;
94
- if (refreshedBind.guardLevel > 0) {
95
- buidInfo += `\n舰长等级: ${refreshedBind.guardLevelText} (${refreshedBind.guardLevel})`;
96
- if (refreshedBind.maxGuardLevel > 0 &&
97
- refreshedBind.maxGuardLevel < refreshedBind.guardLevel) {
98
- buidInfo += `\n历史最高: ${refreshedBind.maxGuardLevelText} (${refreshedBind.maxGuardLevel})`;
99
- }
100
- }
101
- else if (refreshedBind.maxGuardLevel > 0) {
102
- buidInfo += `\n历史舰长: ${refreshedBind.maxGuardLevelText} (${refreshedBind.maxGuardLevel})`;
103
- }
104
- if (refreshedBind.medalName) {
105
- buidInfo += `\n粉丝牌: ${refreshedBind.medalName} Lv.${refreshedBind.medalLevel}`;
106
- }
107
- const messageElements = [koishi_1.h.text(buidInfo)];
108
- if (this.config.showAvatar) {
109
- messageElements.push(koishi_1.h.image(`https://workers.vrp.moe/bilibili/avatar/${refreshedBind.buidUid}?size=160`));
110
- }
111
- return this.deps.sendMessage(session, messageElements);
89
+ let buidInfo = `该用户尚未绑定MC账号\n\nB站账号信息:\nB站UID: ${targetBind.buidUid}\n用户名: ${targetBind.buidUsername}`;
90
+ if (targetBind.guardLevel > 0) {
91
+ buidInfo += `\n舰长等级: ${(0, helpers_1.getGuardLevelText)(targetBind.guardLevel)} (${targetBind.guardLevel})`;
92
+ if (targetBind.maxGuardLevel > 0 &&
93
+ targetBind.maxGuardLevel < targetBind.guardLevel) {
94
+ buidInfo += `\n历史最高: ${(0, helpers_1.getGuardLevelText)(targetBind.maxGuardLevel)} (${targetBind.maxGuardLevel})`;
112
95
  }
113
96
  }
97
+ else if (targetBind.maxGuardLevel > 0) {
98
+ buidInfo += `\n历史舰长: ${(0, helpers_1.getGuardLevelText)(targetBind.maxGuardLevel)} (${targetBind.maxGuardLevel})`;
99
+ }
100
+ if (targetBind.medalName) {
101
+ buidInfo += `\n粉丝牌: ${targetBind.medalName} Lv.${targetBind.medalLevel}`;
102
+ }
103
+ const messageElements = [koishi_1.h.text(buidInfo)];
104
+ if (this.config.showAvatar) {
105
+ messageElements.push(koishi_1.h.image(`https://workers.vrp.moe/bilibili/avatar/${targetBind.buidUid}?size=160`));
106
+ }
107
+ return this.deps.sendMessage(session, messageElements);
114
108
  }
115
109
  return this.deps.sendMessage(session, [koishi_1.h.text('该用户尚未绑定MC账号')]);
116
110
  }
@@ -123,35 +117,28 @@ class McidCommandHandler extends base_handler_1.BaseHandler {
123
117
  const selfBind = await this.deps.databaseService.getMcBindByQQId(normalizedUserId);
124
118
  if (!selfBind || !bind_status_1.BindStatus.hasValidMcBind(selfBind)) {
125
119
  this.logger.info('查询', `QQ(${normalizedUserId})未绑定MC账号`);
126
- // 检查是否绑定了B
120
+ // 检查是否绑定了B站(直接从数据库读取,数据由触发器自动刷新)
127
121
  if (selfBind && selfBind.buidUid) {
128
- const buidUser = await this.deps.apiService.validateBUID(selfBind.buidUid);
129
- if (buidUser) {
130
- await this.deps.databaseService.updateBuidInfoOnly(selfBind.qqId, buidUser);
131
- const refreshedBind = await this.deps.databaseService.getMcBindByQQId(normalizedUserId);
132
- if (refreshedBind) {
133
- let buidInfo = `您尚未绑定MC账号\n\nB站账号信息:\nB站UID: ${refreshedBind.buidUid}\n用户名: ${refreshedBind.buidUsername}`;
134
- if (refreshedBind.guardLevel > 0) {
135
- buidInfo += `\n舰长等级: ${refreshedBind.guardLevelText} (${refreshedBind.guardLevel})`;
136
- if (refreshedBind.maxGuardLevel > 0 &&
137
- refreshedBind.maxGuardLevel < refreshedBind.guardLevel) {
138
- buidInfo += `\n历史最高: ${refreshedBind.maxGuardLevelText} (${refreshedBind.maxGuardLevel})`;
139
- }
140
- }
141
- else if (refreshedBind.maxGuardLevel > 0) {
142
- buidInfo += `\n历史舰长: ${refreshedBind.maxGuardLevelText} (${refreshedBind.maxGuardLevel})`;
143
- }
144
- if (refreshedBind.medalName) {
145
- buidInfo += `\n粉丝牌: ${refreshedBind.medalName} Lv.${refreshedBind.medalLevel}`;
146
- }
147
- buidInfo += `\n\n💡 您可以使用 ${this.deps.formatCommand('mcid bind <用户名>')} 绑定MC账号`;
148
- const messageElements = [koishi_1.h.text(buidInfo)];
149
- if (this.config.showAvatar) {
150
- messageElements.push(koishi_1.h.image(`https://workers.vrp.moe/bilibili/avatar/${refreshedBind.buidUid}?size=160`));
151
- }
152
- return this.deps.sendMessage(session, messageElements);
122
+ let buidInfo = `您尚未绑定MC账号\n\nB站账号信息:\nB站UID: ${selfBind.buidUid}\n用户名: ${selfBind.buidUsername}`;
123
+ if (selfBind.guardLevel > 0) {
124
+ buidInfo += `\n舰长等级: ${(0, helpers_1.getGuardLevelText)(selfBind.guardLevel)} (${selfBind.guardLevel})`;
125
+ if (selfBind.maxGuardLevel > 0 &&
126
+ selfBind.maxGuardLevel < selfBind.guardLevel) {
127
+ buidInfo += `\n历史最高: ${(0, helpers_1.getGuardLevelText)(selfBind.maxGuardLevel)} (${selfBind.maxGuardLevel})`;
153
128
  }
154
129
  }
130
+ else if (selfBind.maxGuardLevel > 0) {
131
+ buidInfo += `\n历史舰长: ${(0, helpers_1.getGuardLevelText)(selfBind.maxGuardLevel)} (${selfBind.maxGuardLevel})`;
132
+ }
133
+ if (selfBind.medalName) {
134
+ buidInfo += `\n粉丝牌: ${selfBind.medalName} Lv.${selfBind.medalLevel}`;
135
+ }
136
+ buidInfo += `\n\n💡 您可以使用 ${this.deps.formatCommand('mcid bind <用户名>')} 绑定MC账号`;
137
+ const messageElements = [koishi_1.h.text(buidInfo)];
138
+ if (this.config.showAvatar) {
139
+ messageElements.push(koishi_1.h.image(`https://workers.vrp.moe/bilibili/avatar/${selfBind.buidUid}?size=160`));
140
+ }
141
+ return this.deps.sendMessage(session, messageElements);
155
142
  }
156
143
  return this.deps.sendMessage(session, [
157
144
  koishi_1.h.text('您尚未绑定MC账号,请使用 ' +
@@ -217,13 +204,13 @@ class McidCommandHandler extends base_handler_1.BaseHandler {
217
204
  if (bind.buidUid) {
218
205
  buidInfo = `B站账号信息:\nB站UID: ${bind.buidUid}\n用户名: ${bind.buidUsername}`;
219
206
  if (bind.guardLevel > 0) {
220
- buidInfo += `\n舰长等级: ${bind.guardLevelText} (${bind.guardLevel})`;
207
+ buidInfo += `\n舰长等级: ${(0, helpers_1.getGuardLevelText)(bind.guardLevel)} (${bind.guardLevel})`;
221
208
  if (bind.maxGuardLevel > 0 && bind.maxGuardLevel < bind.guardLevel) {
222
- buidInfo += `\n历史最高: ${bind.maxGuardLevelText} (${bind.maxGuardLevel})`;
209
+ buidInfo += `\n历史最高: ${(0, helpers_1.getGuardLevelText)(bind.maxGuardLevel)} (${bind.maxGuardLevel})`;
223
210
  }
224
211
  }
225
212
  else if (bind.maxGuardLevel > 0) {
226
- buidInfo += `\n历史舰长: ${bind.maxGuardLevelText} (${bind.maxGuardLevel})`;
213
+ buidInfo += `\n历史舰长: ${(0, helpers_1.getGuardLevelText)(bind.maxGuardLevel)} (${bind.maxGuardLevel})`;
227
214
  }
228
215
  if (bind.medalName) {
229
216
  buidInfo += `\n粉丝牌: ${bind.medalName} Lv.${bind.medalLevel}`;