koishi-plugin-bind-bot 2.2.1 → 2.2.3

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.
@@ -618,8 +618,8 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
618
618
  // 创建新绑定(不使用临时MC用户名)
619
619
  bind = await this.repos.mcidbind.create({
620
620
  qqId: qq,
621
- mcUsername: '',
622
- mcUuid: '',
621
+ mcUsername: null,
622
+ mcUuid: null,
623
623
  buidUid: zminfoUser.uid,
624
624
  buidUsername: finalUsername,
625
625
  guardLevel: zminfoUser.guard_level || 0,
package/lib/index.js CHANGED
@@ -578,11 +578,11 @@ function apply(ctx, config) {
578
578
  },
579
579
  mcUsername: {
580
580
  type: 'string',
581
- initial: ''
581
+ initial: null
582
582
  },
583
583
  mcUuid: {
584
584
  type: 'string',
585
- initial: ''
585
+ initial: null
586
586
  },
587
587
  lastModified: {
588
588
  type: 'timestamp',
@@ -670,11 +670,6 @@ function apply(ctx, config) {
670
670
  // 添加isAdmin索引,提高查询效率
671
671
  indexes: [['isAdmin'], ['buidUid']]
672
672
  });
673
- // 在插件启动时执行数据迁移
674
- ctx.on('ready', async () => {
675
- logger.info('[初始化] 开始数据迁移和一致性检查...');
676
- await addMissingFields();
677
- });
678
673
  // 检查表结构是否包含旧字段
679
674
  const checkTableStructure = async () => {
680
675
  try {
@@ -746,8 +741,8 @@ function apply(ctx, config) {
746
741
  }
747
742
  // 清理临时用户名(无论hasMcBind字段是否存在)
748
743
  if (!hasValidMc && mcUsername && mcUsername.startsWith('_temp_')) {
749
- updateData.mcUsername = '';
750
- updateData.mcUuid = '';
744
+ updateData.mcUsername = null;
745
+ updateData.mcUuid = null;
751
746
  updateData.whitelist = [];
752
747
  needUpdate = true;
753
748
  logger.info(`[数据清理] 清理QQ(${qqId})的临时用户名: ${mcUsername}`);
@@ -787,6 +782,11 @@ function apply(ctx, config) {
787
782
  return false;
788
783
  }
789
784
  };
785
+ // 在插件启动时执行数据迁移(放在函数定义之后)
786
+ ctx.on('ready', async () => {
787
+ logger.info('[初始化] 开始数据迁移和一致性检查...');
788
+ await addMissingFields();
789
+ });
790
790
  // 重建MCIDBIND表
791
791
  const rebuildMcidBindTable = async () => {
792
792
  try {
@@ -146,8 +146,8 @@ class DatabaseService {
146
146
  if (bind_status_1.BindStatus.hasValidBuidBind(bind)) {
147
147
  // 如果有B站绑定,只清空MC字段,保留记录
148
148
  await this.mcidbindRepo.update(normalizedQQId, {
149
- mcUsername: '',
150
- mcUuid: '',
149
+ mcUsername: null,
150
+ mcUuid: null,
151
151
  hasMcBind: false,
152
152
  whitelist: [],
153
153
  lastModified: new Date()
@@ -295,8 +295,8 @@ class DatabaseService {
295
295
  // 创建新绑定记录(不使用临时用户名)
296
296
  const newBind = {
297
297
  qqId: normalizedQQId,
298
- mcUsername: '',
299
- mcUuid: '',
298
+ mcUsername: null,
299
+ mcUuid: null,
300
300
  isAdmin: false,
301
301
  whitelist: [],
302
302
  tags: [],
@@ -38,10 +38,10 @@
38
38
  export interface MCIDBIND {
39
39
  /** 纯QQ号 (作为主键, 不包含 'qq:' 前缀) */
40
40
  qqId: string;
41
- /** MC用户名 (具有唯一性约束) */
42
- mcUsername: string;
43
- /** MC UUID (格式: 带连字符的标准UUID) */
44
- mcUuid: string;
41
+ /** MC用户名 (具有唯一性约束, NULL表示未绑定) */
42
+ mcUsername: string | null;
43
+ /** MC UUID (格式: 带连字符的标准UUID, NULL表示未绑定) */
44
+ mcUuid: string | null;
45
45
  /** MC用户名上次检查时间 (用于改名检测缓存) */
46
46
  usernameLastChecked?: Date;
47
47
  /** 用户名检查失败次数 (连续失败计数, 失败≥3次延长冷却期至72小时) */
@@ -24,10 +24,10 @@
24
24
  * ```
25
25
  */
26
26
  export interface UpdateMcBindData {
27
- /** MC用户名 */
28
- mcUsername?: string;
29
- /** MC UUID */
30
- mcUuid?: string;
27
+ /** MC用户名 (NULL表示未绑定) */
28
+ mcUsername?: string | null;
29
+ /** MC UUID (NULL表示未绑定) */
30
+ mcUuid?: string | null;
31
31
  /** 上次修改时间 */
32
32
  lastModified?: Date;
33
33
  /** 是否为管理员 */
@@ -134,8 +134,8 @@ export interface UpdateBuidInfoData {
134
134
  */
135
135
  export interface CreateBindData {
136
136
  qqId: string;
137
- mcUsername: string;
138
- mcUuid: string;
137
+ mcUsername: string | null;
138
+ mcUuid: string | null;
139
139
  isAdmin: boolean;
140
140
  whitelist: string[];
141
141
  tags: string[];
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.1",
4
+ "version": "2.2.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [