koishi-plugin-bind-bot 2.0.0 → 2.0.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.
- package/LICENSE +35 -0
- package/lib/handlers/base.handler.d.ts +16 -1
- package/lib/handlers/mcid.handler.d.ts +3 -39
- package/lib/handlers/mcid.handler.js +147 -150
- package/lib/handlers/whitelist.handler.d.ts +0 -4
- package/lib/handlers/whitelist.handler.js +9 -34
- package/lib/index.js +126 -162
- package/lib/repositories/mcidbind.repository.d.ts +13 -1
- package/lib/repositories/mcidbind.repository.js +50 -1
- package/lib/types/database.d.ts +2 -0
- package/lib/utils/error-utils.d.ts +30 -0
- package/lib/utils/error-utils.js +111 -0
- package/lib/utils/helpers.d.ts +33 -0
- package/lib/utils/helpers.js +87 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
BIND-BOT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 WittF
|
|
4
|
+
|
|
5
|
+
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
|
|
6
|
+
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
7
|
+
|
|
8
|
+
您可以自由地:
|
|
9
|
+
You are free to:
|
|
10
|
+
- 共享 — 在任何媒介以任何形式复制、发行本作品
|
|
11
|
+
Share — copy and redistribute the material in any medium or format
|
|
12
|
+
- 演绎 — 修改、转换或以本作品为基础进行创作
|
|
13
|
+
Adapt — remix, transform, and build upon the material
|
|
14
|
+
|
|
15
|
+
惟须遵守下列条件:
|
|
16
|
+
Under the following terms:
|
|
17
|
+
- 署名 — 您必须给出适当的署名,提供指向本许可协议的链接,同时标明是否(对原始作品)作了修改。您可以用任何合理的方式来署名,但是不得以任何方式暗示许可人为您或您的使用背书。
|
|
18
|
+
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
|
19
|
+
|
|
20
|
+
- 非商业性使用 — 您不得将本作品用于商业目的。
|
|
21
|
+
NonCommercial — You may not use the material for commercial purposes.
|
|
22
|
+
|
|
23
|
+
- 相同方式共享 — 如果您再混合、转换或者基于本作品进行创作,您必须基于与原先许可协议相同的许可协议分发您贡献的作品。
|
|
24
|
+
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
|
|
25
|
+
|
|
26
|
+
没有附加限制 — 您不得适用法律术语或者技术措施从而限制其他人做许可协议允许的事情。
|
|
27
|
+
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
|
|
28
|
+
|
|
29
|
+
完整许可协议文本:
|
|
30
|
+
Full license text:
|
|
31
|
+
https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
|
|
32
|
+
|
|
33
|
+
中文版本:
|
|
34
|
+
Chinese version:
|
|
35
|
+
https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.zh-Hans
|
|
@@ -25,9 +25,24 @@ export interface HandlerDependencies {
|
|
|
25
25
|
checkCooldown: (lastModified: Date | null, multiplier?: number) => boolean;
|
|
26
26
|
getCrafatarUrl: (uuid: string) => string;
|
|
27
27
|
getStarlightSkinUrl: (uuid: string) => string;
|
|
28
|
+
getMcBindByQQId: (qqId: string) => Promise<MCIDBIND | null>;
|
|
29
|
+
getMcBindByUsername: (username: string) => Promise<MCIDBIND | null>;
|
|
30
|
+
createOrUpdateMcBind: (userId: string, username: string, uuid: string, isAdmin?: boolean) => Promise<boolean>;
|
|
31
|
+
deleteMcBind: (userId: string) => Promise<boolean>;
|
|
32
|
+
checkUsernameExists: (username: string, currentUserId?: string, uuid?: string) => Promise<boolean>;
|
|
33
|
+
checkAndUpdateUsername: (bind: MCIDBIND) => Promise<MCIDBIND>;
|
|
34
|
+
checkAndUpdateUsernameWithCache: (bind: MCIDBIND) => Promise<MCIDBIND>;
|
|
35
|
+
validateUsername: (username: string) => Promise<any>;
|
|
36
|
+
validateBUID: (uid: string) => Promise<any>;
|
|
37
|
+
updateBuidInfoOnly: (qqId: string, buidUser: any) => Promise<boolean>;
|
|
38
|
+
isAdmin: (userId: string) => Promise<boolean>;
|
|
39
|
+
isMaster: (userId: string) => boolean;
|
|
28
40
|
sendMessage: (session: Session, content: any[], options?: any) => Promise<void>;
|
|
29
|
-
autoSetGroupNickname: (session: Session, mcUsername: string, buidUsername: string, targetUserId?: string, specifiedGroupId?: string) => Promise<void>;
|
|
41
|
+
autoSetGroupNickname: (session: Session, mcUsername: string | null, buidUsername: string, targetUserId?: string, specifiedGroupId?: string) => Promise<void>;
|
|
42
|
+
checkNicknameFormat: (nickname: string, buidUsername: string, mcUsername: string | null) => boolean;
|
|
30
43
|
getBindInfo: (qqId: string) => Promise<MCIDBIND | null>;
|
|
44
|
+
getServerConfigById: (serverId: string) => any;
|
|
45
|
+
getFriendlyErrorMessage: (error: any) => string;
|
|
31
46
|
rconManager: RconManager;
|
|
32
47
|
messageUtils: MessageUtils;
|
|
33
48
|
forceBinder: ForceBinder;
|
|
@@ -1,44 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { GroupExporter } from '../export-utils';
|
|
4
|
-
import type { Config, ServerConfig, MCIDBIND, MojangProfile } from '../types';
|
|
5
|
-
interface McidHandlerDeps {
|
|
6
|
-
config: Config;
|
|
7
|
-
logger: LoggerService;
|
|
8
|
-
mcidbindRepo: any;
|
|
9
|
-
groupExporter: GroupExporter;
|
|
10
|
-
normalizeQQId: (userId: string) => string;
|
|
11
|
-
formatCommand: (cmd: string) => string;
|
|
12
|
-
formatUuid: (uuid: string) => string;
|
|
13
|
-
checkCooldown: (lastModified: Date) => boolean;
|
|
14
|
-
getCrafatarUrl: (uuid: string) => string | null;
|
|
15
|
-
getStarlightSkinUrl: (username: string) => string | null;
|
|
16
|
-
getMcBindByQQId: (qqId: string) => Promise<MCIDBIND | null>;
|
|
17
|
-
getMcBindByUsername: (username: string) => Promise<MCIDBIND | null>;
|
|
18
|
-
createOrUpdateMcBind: (userId: string, username: string, uuid: string, isAdmin?: boolean) => Promise<boolean>;
|
|
19
|
-
deleteMcBind: (userId: string) => Promise<boolean>;
|
|
20
|
-
checkUsernameExists: (username: string, currentUserId?: string) => Promise<boolean>;
|
|
21
|
-
checkAndUpdateUsername: (bind: MCIDBIND) => Promise<MCIDBIND>;
|
|
22
|
-
validateUsername: (username: string) => Promise<MojangProfile | null>;
|
|
23
|
-
validateBUID: (uid: string) => Promise<any>;
|
|
24
|
-
updateBuidInfoOnly: (qqId: string, buidUser: any) => Promise<boolean>;
|
|
25
|
-
isAdmin: (userId: string) => Promise<boolean>;
|
|
26
|
-
isMaster: (userId: string) => boolean;
|
|
27
|
-
sendMessage: (session: Session, content: any[]) => Promise<void>;
|
|
28
|
-
autoSetGroupNickname: (session: Session, mcName: string | null, buidUsername: string, targetUserId?: string, specifiedGroupId?: string) => Promise<void>;
|
|
29
|
-
checkNicknameFormat: (nickname: string, buidUsername: string, mcName: string | null) => boolean;
|
|
30
|
-
removeBindingSession: (userId: string, channelId: string) => void;
|
|
31
|
-
getServerConfigById: (serverId: string) => ServerConfig | null;
|
|
32
|
-
getFriendlyErrorMessage: (error: any) => string;
|
|
33
|
-
}
|
|
34
|
-
export declare class McidCommandHandler {
|
|
35
|
-
private ctx;
|
|
36
|
-
private deps;
|
|
37
|
-
constructor(ctx: Context, deps: McidHandlerDeps);
|
|
1
|
+
import { BaseHandler } from './base.handler';
|
|
2
|
+
export declare class McidCommandHandler extends BaseHandler {
|
|
38
3
|
/**
|
|
39
4
|
* 注册所有MCID命令
|
|
40
5
|
*/
|
|
41
|
-
|
|
6
|
+
register(): void;
|
|
42
7
|
/**
|
|
43
8
|
* 查询MC账号
|
|
44
9
|
*/
|
|
@@ -98,4 +63,3 @@ export declare class McidCommandHandler {
|
|
|
98
63
|
*/
|
|
99
64
|
private handleExport;
|
|
100
65
|
}
|
|
101
|
-
export {};
|