koishi-plugin-adapter-onebot-multi 1.0.6 → 2.0.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.
- package/client/components/BotEditorModal.vue +260 -0
- package/client/components/BotEditorModal.vue.bak +54 -0
- package/client/page.vue +605 -1071
- package/client/page.vue.bak +1083 -0
- package/dist/index.js +7 -7
- package/dist/style.css +1 -1
- package/lib/activation-store.d.ts +1 -0
- package/lib/index.js +142 -64
- package/lib/load-balancer.d.ts +1 -0
- package/lib/ws.d.ts +1 -2
- package/package.json +1 -1
- package/lib/admin.d.ts +0 -52
- package/lib/config-manager.d.ts +0 -83
- package/lib/csv-sync.d.ts +0 -19
- package/lib/panel.d.ts +0 -25
package/package.json
CHANGED
package/lib/admin.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { ConfigManager, BotConfigRecord } from './config-manager';
|
|
3
|
-
import { StatusManager, BotStatus } from './status';
|
|
4
|
-
export interface BotFullInfo extends BotStatus {
|
|
5
|
-
config: Omit<BotConfigRecord, 'token'>;
|
|
6
|
-
}
|
|
7
|
-
export interface AdminPanelData {
|
|
8
|
-
bots: BotFullInfo[];
|
|
9
|
-
updatedAt: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Console 管理面板服务
|
|
13
|
-
* 提供 Bot 配置的增删改查 API
|
|
14
|
-
*/
|
|
15
|
-
export declare function setupAdminPanel(ctx: Context, configManager: ConfigManager, statusManager: StatusManager): void;
|
|
16
|
-
declare module '@koishijs/console' {
|
|
17
|
-
interface Events {
|
|
18
|
-
'onebot-multi/admin/list'(): Promise<AdminPanelData>;
|
|
19
|
-
'onebot-multi/admin/create'(data: {
|
|
20
|
-
selfId: string;
|
|
21
|
-
token?: string;
|
|
22
|
-
protocol: 'ws' | 'ws-reverse';
|
|
23
|
-
endpoint?: string;
|
|
24
|
-
path?: string;
|
|
25
|
-
}): Promise<{
|
|
26
|
-
success: boolean;
|
|
27
|
-
record: BotConfigRecord;
|
|
28
|
-
}>;
|
|
29
|
-
'onebot-multi/admin/update'(data: {
|
|
30
|
-
selfId: string;
|
|
31
|
-
updates: {
|
|
32
|
-
token?: string;
|
|
33
|
-
protocol?: 'ws' | 'ws-reverse';
|
|
34
|
-
endpoint?: string;
|
|
35
|
-
path?: string;
|
|
36
|
-
};
|
|
37
|
-
}): Promise<{
|
|
38
|
-
success: boolean;
|
|
39
|
-
needRestart: boolean;
|
|
40
|
-
}>;
|
|
41
|
-
'onebot-multi/admin/delete'(selfId: string): Promise<{
|
|
42
|
-
success: boolean;
|
|
43
|
-
}>;
|
|
44
|
-
'onebot-multi/admin/toggle'(selfId: string): Promise<{
|
|
45
|
-
success: boolean;
|
|
46
|
-
enabled: boolean;
|
|
47
|
-
}>;
|
|
48
|
-
'onebot-multi/admin/restart'(selfId: string): Promise<{
|
|
49
|
-
success: boolean;
|
|
50
|
-
}>;
|
|
51
|
-
}
|
|
52
|
-
}
|
package/lib/config-manager.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import type { BotConfig } from './index';
|
|
3
|
-
declare module 'koishi' {
|
|
4
|
-
interface Tables {
|
|
5
|
-
'onebot_multi_bots': BotConfigRecord;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export interface BotConfigRecord {
|
|
9
|
-
id: number;
|
|
10
|
-
name: string;
|
|
11
|
-
selfId?: string;
|
|
12
|
-
token?: string;
|
|
13
|
-
protocol: 'ws' | 'ws-reverse';
|
|
14
|
-
endpoint?: string;
|
|
15
|
-
path?: string;
|
|
16
|
-
enabled: boolean;
|
|
17
|
-
createdAt: Date;
|
|
18
|
-
updatedAt: Date;
|
|
19
|
-
}
|
|
20
|
-
export declare class ConfigManager {
|
|
21
|
-
private ctx;
|
|
22
|
-
constructor(ctx: Context);
|
|
23
|
-
/**
|
|
24
|
-
* 获取存储的密码哈希
|
|
25
|
-
*/
|
|
26
|
-
private getStoredPasswordHash;
|
|
27
|
-
/**
|
|
28
|
-
* 设置管理密码(哈希存储)
|
|
29
|
-
*/
|
|
30
|
-
setAdminPassword(password: string): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* 检查是否已设置密码
|
|
33
|
-
*/
|
|
34
|
-
hasAdminPassword(): Promise<boolean>;
|
|
35
|
-
/**
|
|
36
|
-
* 验证管理密码
|
|
37
|
-
*/
|
|
38
|
-
verifyAdminPassword(password: string): Promise<boolean>;
|
|
39
|
-
/**
|
|
40
|
-
* 获取所有 Bot 配置(排除系统配置)
|
|
41
|
-
*/
|
|
42
|
-
getAllConfigs(): Promise<BotConfigRecord[]>;
|
|
43
|
-
/**
|
|
44
|
-
* 获取启用的 Bot 配置(排除系统配置)
|
|
45
|
-
*/
|
|
46
|
-
getEnabledConfigs(): Promise<BotConfigRecord[]>;
|
|
47
|
-
/**
|
|
48
|
-
* 根据 ID 获取单个 Bot 配置
|
|
49
|
-
*/
|
|
50
|
-
getConfigById(id: number): Promise<BotConfigRecord | undefined>;
|
|
51
|
-
/**
|
|
52
|
-
* 根据 selfId 获取配置(用于关联运行时 Bot)
|
|
53
|
-
*/
|
|
54
|
-
getConfigBySelfId(selfId: string): Promise<BotConfigRecord | undefined>;
|
|
55
|
-
/**
|
|
56
|
-
* 创建 Bot 配置
|
|
57
|
-
*/
|
|
58
|
-
createConfig(config: Omit<BotConfigRecord, 'id' | 'selfId' | 'createdAt' | 'updatedAt'> & {
|
|
59
|
-
selfId?: string;
|
|
60
|
-
}): Promise<BotConfigRecord>;
|
|
61
|
-
/**
|
|
62
|
-
* 更新 Bot 配置(根据 ID)
|
|
63
|
-
*/
|
|
64
|
-
updateConfigById(id: number, updates: Partial<Omit<BotConfigRecord, 'id' | 'createdAt'>>): Promise<boolean>;
|
|
65
|
-
/**
|
|
66
|
-
* 删除 Bot 配置(根据 ID)
|
|
67
|
-
*/
|
|
68
|
-
deleteConfigById(id: number): Promise<boolean>;
|
|
69
|
-
/**
|
|
70
|
-
* 切换 Bot 启用状态
|
|
71
|
-
*/
|
|
72
|
-
toggleEnabled(id: number): Promise<boolean>;
|
|
73
|
-
/**
|
|
74
|
-
* 更新配置的 selfId(Bot 连接成功后调用)
|
|
75
|
-
*/
|
|
76
|
-
updateSelfId(id: number, selfId: string): Promise<boolean>;
|
|
77
|
-
/**
|
|
78
|
-
* 将数据库配置转换为 BotConfig 格式(用于启动 Bot)
|
|
79
|
-
*/
|
|
80
|
-
toBotConfig(record: BotConfigRecord): BotConfig & {
|
|
81
|
-
configId: number;
|
|
82
|
-
};
|
|
83
|
-
}
|
package/lib/csv-sync.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { ConfigStore } from './config-store';
|
|
3
|
-
import { LoadBalancer } from './load-balancer';
|
|
4
|
-
export declare class CsvSyncManager {
|
|
5
|
-
private ctx;
|
|
6
|
-
private configStore;
|
|
7
|
-
private loadBalancer;
|
|
8
|
-
private logger;
|
|
9
|
-
private csvPath;
|
|
10
|
-
constructor(ctx: Context, configStore: ConfigStore, loadBalancer: LoadBalancer);
|
|
11
|
-
/**
|
|
12
|
-
* 手动触发同步 CSV 到 PriorityChannels
|
|
13
|
-
*/
|
|
14
|
-
syncFromCsv(): {
|
|
15
|
-
success: boolean;
|
|
16
|
-
count: number;
|
|
17
|
-
error?: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
package/lib/panel.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Context, Schema } from 'koishi';
|
|
2
|
-
import { StatusManager } from './status';
|
|
3
|
-
import { ConfigManager } from './config-manager';
|
|
4
|
-
export interface PanelConfig {
|
|
5
|
-
enabled?: boolean;
|
|
6
|
-
basePath?: string;
|
|
7
|
-
port?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare const PanelConfig: Schema<PanelConfig>;
|
|
10
|
-
export declare class StatusPanel {
|
|
11
|
-
private ctx;
|
|
12
|
-
private config;
|
|
13
|
-
private statusManager;
|
|
14
|
-
private configManager;
|
|
15
|
-
private app?;
|
|
16
|
-
private server?;
|
|
17
|
-
constructor(ctx: Context, config: PanelConfig, statusManager: StatusManager, configManager: ConfigManager);
|
|
18
|
-
private parseJsonBody;
|
|
19
|
-
private setupRoutes;
|
|
20
|
-
private startBot;
|
|
21
|
-
private stopBot;
|
|
22
|
-
private renderAdminApp;
|
|
23
|
-
private renderStatusPage;
|
|
24
|
-
private formatUptime;
|
|
25
|
-
}
|