koishi-plugin-bind-bot 2.2.2 → 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.
- package/lib/handlers/buid.handler.js +2 -2
- package/lib/handlers/group-request-review.handler.js +13 -10
- package/lib/handlers/mcid.handler.js +2 -2
- package/lib/handlers/tag.handler.js +4 -4
- package/lib/index.js +6 -6
- package/lib/services/database.service.js +6 -6
- package/lib/types/database.d.ts +8 -8
- package/lib/types/update-data.d.ts +10 -10
- package/package.json +1 -1
|
@@ -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
|
|
527
|
+
// 格式3: UID:123456789 或 UID:123456789 用户名(参考BuidHandler)
|
|
528
528
|
if (input.toLowerCase().startsWith('uid:')) {
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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:
|
|
557
|
-
|
|
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:
|
|
562
|
+
this.logger.debug('入群审批', `parseUID: 从文本提取数字串 -> ${numberMatch[1]}`);
|
|
560
563
|
return numberMatch[1];
|
|
561
564
|
}
|
|
562
565
|
this.logger.warn('入群审批', `parseUID: 无法解析 - "${input}"`);
|
|
@@ -618,8 +621,8 @@ class GroupRequestReviewHandler extends base_handler_1.BaseHandler {
|
|
|
618
621
|
// 创建新绑定(不使用临时MC用户名)
|
|
619
622
|
bind = await this.repos.mcidbind.create({
|
|
620
623
|
qqId: qq,
|
|
621
|
-
mcUsername:
|
|
622
|
-
mcUuid:
|
|
624
|
+
mcUsername: null,
|
|
625
|
+
mcUuid: null,
|
|
623
626
|
buidUid: zminfoUser.uid,
|
|
624
627
|
buidUsername: finalUsername,
|
|
625
628
|
guardLevel: zminfoUser.guard_level || 0,
|
|
@@ -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
|
@@ -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',
|
|
@@ -741,8 +741,8 @@ function apply(ctx, config) {
|
|
|
741
741
|
}
|
|
742
742
|
// 清理临时用户名(无论hasMcBind字段是否存在)
|
|
743
743
|
if (!hasValidMc && mcUsername && mcUsername.startsWith('_temp_')) {
|
|
744
|
-
updateData.mcUsername =
|
|
745
|
-
updateData.mcUuid =
|
|
744
|
+
updateData.mcUsername = null;
|
|
745
|
+
updateData.mcUuid = null;
|
|
746
746
|
updateData.whitelist = [];
|
|
747
747
|
needUpdate = true;
|
|
748
748
|
logger.info(`[数据清理] 清理QQ(${qqId})的临时用户名: ${mcUsername}`);
|
|
@@ -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: [],
|
|
@@ -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: [],
|
|
@@ -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,
|
package/lib/types/database.d.ts
CHANGED
|
@@ -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小时) */
|
|
@@ -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
|
/** 当前舰长等级文本 (例: '舰长', '提督', '总督') */
|
|
@@ -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
|
/** 是否为管理员 */
|
|
@@ -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
|
/** 当前舰长等级文本 */
|
|
@@ -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[];
|