koishi-plugin-bind-bot 2.2.3 → 2.2.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.
@@ -398,8 +398,8 @@ class BuidHandler extends base_handler_1.BaseHandler {
398
398
  else {
399
399
  const newBind = {
400
400
  qqId: normalizedQQId,
401
- mcUsername: '',
402
- mcUuid: '',
401
+ mcUsername: null,
402
+ mcUuid: null,
403
403
  isAdmin: false,
404
404
  whitelist: [],
405
405
  tags: [],
@@ -524,12 +524,14 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
524
524
  this.logger.debug('入群审批', `parseUID: 从"答案:"提取 -> ${answerMatch[1]}`);
525
525
  return answerMatch[1];
526
526
  }
527
- // 格式3: UID:123456789(参考BuidHandler)
527
+ // 格式3: UID:123456789 或 UID:123456789 用户名(参考BuidHandler)
528
528
  if (input.toLowerCase().startsWith('uid:')) {
529
- const uid = input.substring(4).trim();
530
- if (/^\d+$/.test(uid)) {
531
- this.logger.debug('入群审批', `parseUID: 从"UID:"前缀提取 -> ${uid}`);
532
- return uid;
529
+ const afterPrefix = input.substring(4).trim();
530
+ // 提取第一个连续的数字串(支持后面跟着其他内容)
531
+ const uidMatch = afterPrefix.match(/^(\d+)/);
532
+ if (uidMatch) {
533
+ this.logger.debug('入群审批', `parseUID: 从"UID:"前缀提取 -> ${uidMatch[1]}`);
534
+ return uidMatch[1];
533
535
  }
534
536
  }
535
537
  // 格式4: https://space.bilibili.com/123456789(参考BuidHandler的完善处理)
@@ -553,10 +555,11 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
553
555
  this.logger.warn('入群审批', `parseUID: URL解析失败 - ${error.message}`);
554
556
  }
555
557
  }
556
- // 格式5: 从文本中提取第一个长数字串(8-12位,B站UID的典型长度)
557
- const numberMatch = input.match(/\b(\d{8,12})\b/);
558
+ // 格式5: 从文本中提取第一个数字串(4位及以上,避免误匹配过短的序号)
559
+ // 注:B站UID可以是1-2位,但在混合文本中用4位作为最小值可减少误匹配
560
+ const numberMatch = input.match(/\b(\d{4,})\b/);
558
561
  if (numberMatch) {
559
- this.logger.debug('入群审批', `parseUID: 从文本提取长数字串 -> ${numberMatch[1]}`);
562
+ this.logger.debug('入群审批', `parseUID: 从文本提取数字串 -> ${numberMatch[1]}`);
560
563
  return numberMatch[1];
561
564
  }
562
565
  this.logger.warn('入群审批', `parseUID: 无法解析 - "${input}"`);
@@ -777,8 +777,8 @@ class McidCommandHandler extends base_handler_1.BaseHandler {
777
777
  try {
778
778
  await this.repos.mcidbind.create({
779
779
  qqId: normalizedTargetId,
780
- mcUsername: '',
781
- mcUuid: '',
780
+ mcUsername: null,
781
+ mcUuid: null,
782
782
  lastModified: new Date(),
783
783
  isAdmin: true,
784
784
  hasMcBind: false,
@@ -81,8 +81,8 @@ class TagHandler extends base_handler_1.BaseHandler {
81
81
  if (!targetBind) {
82
82
  await this.repos.mcidbind.create({
83
83
  qqId: normalizedTargetId,
84
- mcUsername: '',
85
- mcUuid: '',
84
+ mcUsername: null,
85
+ mcUuid: null,
86
86
  lastModified: new Date(),
87
87
  isAdmin: false,
88
88
  whitelist: [],
@@ -119,8 +119,8 @@ class TagHandler extends base_handler_1.BaseHandler {
119
119
  if (!targetBind) {
120
120
  await this.repos.mcidbind.create({
121
121
  qqId: normalizedTargetId,
122
- mcUsername: '',
123
- mcUuid: '',
122
+ mcUsername: null,
123
+ mcUuid: null,
124
124
  lastModified: new Date(),
125
125
  isAdmin: false,
126
126
  whitelist: [],
package/lib/index.js CHANGED
@@ -1316,8 +1316,8 @@ function apply(ctx, config) {
1316
1316
  // 创建新记录
1317
1317
  await mcidbindRepo.create({
1318
1318
  qqId: normalizedUserId,
1319
- mcUsername: '',
1320
- mcUuid: '',
1319
+ mcUsername: null,
1320
+ mcUuid: null,
1321
1321
  lastModified: new Date(),
1322
1322
  isAdmin: false,
1323
1323
  whitelist: [],
@@ -383,8 +383,8 @@ class DatabaseService {
383
383
  if (bind_status_1.BindStatus.hasValidMcBind(bind)) {
384
384
  // 如果有MC绑定,只清空B站字段,保留记录
385
385
  await this.mcidbindRepo.update(normalizedQQId, {
386
- buidUid: '',
387
- buidUsername: '',
386
+ buidUid: null,
387
+ buidUsername: null,
388
388
  guardLevel: 0,
389
389
  guardLevelText: '',
390
390
  maxGuardLevel: 0,
@@ -54,10 +54,10 @@ export interface MCIDBIND {
54
54
  whitelist: string[];
55
55
  /** 用户标签列表 (用于分类管理) */
56
56
  tags: string[];
57
- /** B站UID */
58
- buidUid: string;
59
- /** B站用户名 */
60
- buidUsername: string;
57
+ /** B站UID (NULL表示未绑定) */
58
+ buidUid: string | null;
59
+ /** B站用户名 (NULL表示未绑定) */
60
+ buidUsername: string | null;
61
61
  /** 当前舰长等级 (0=无, 1=总督, 2=提督, 3=舰长) */
62
62
  guardLevel: number;
63
63
  /** 当前舰长等级文本 (例: '舰长', '提督', '总督') */
@@ -66,10 +66,10 @@ export interface UpdateMcBindData {
66
66
  * ```
67
67
  */
68
68
  export interface UpdateBuidBindData {
69
- /** B站UID (数据库中存储为字符串) */
70
- buidUid?: string;
71
- /** B站用户名 */
72
- buidUsername?: string;
69
+ /** B站UID (数据库中存储为字符串, NULL表示未绑定) */
70
+ buidUid?: string | null;
71
+ /** B站用户名 (NULL表示未绑定) */
72
+ buidUsername?: string | null;
73
73
  /** 当前舰长等级 */
74
74
  guardLevel?: number;
75
75
  /** 当前舰长等级文本 */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-bind-bot",
3
3
  "description": "[WittF自用] BIND-BOT - 账号绑定管理机器人,支持Minecraft账号和B站账号绑定与管理。",
4
- "version": "2.2.3",
4
+ "version": "2.2.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [