koishi-plugin-adapter-onebot-multi 0.0.1 → 0.0.2

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.
@@ -7,7 +7,8 @@ declare module 'koishi' {
7
7
  }
8
8
  export interface BotConfigRecord {
9
9
  id: number;
10
- selfId: string;
10
+ name: string;
11
+ selfId?: string;
11
12
  token?: string;
12
13
  protocol: 'ws' | 'ws-reverse';
13
14
  endpoint?: string;
@@ -44,27 +45,39 @@ export declare class ConfigManager {
44
45
  */
45
46
  getEnabledConfigs(): Promise<BotConfigRecord[]>;
46
47
  /**
47
- * 获取单个 Bot 配置
48
+ * 根据 ID 获取单个 Bot 配置
48
49
  */
49
- getConfig(selfId: string): Promise<BotConfigRecord | undefined>;
50
+ getConfigById(id: number): Promise<BotConfigRecord | undefined>;
51
+ /**
52
+ * 根据 selfId 获取配置(用于关联运行时 Bot)
53
+ */
54
+ getConfigBySelfId(selfId: string): Promise<BotConfigRecord | undefined>;
50
55
  /**
51
56
  * 创建 Bot 配置
52
57
  */
53
- createConfig(config: Omit<BotConfigRecord, 'id' | 'createdAt' | 'updatedAt'>): Promise<BotConfigRecord>;
58
+ createConfig(config: Omit<BotConfigRecord, 'id' | 'selfId' | 'createdAt' | 'updatedAt'> & {
59
+ selfId?: string;
60
+ }): Promise<BotConfigRecord>;
54
61
  /**
55
- * 更新 Bot 配置
62
+ * 更新 Bot 配置(根据 ID)
56
63
  */
57
- updateConfig(selfId: string, updates: Partial<Omit<BotConfigRecord, 'id' | 'selfId' | 'createdAt'>>): Promise<boolean>;
64
+ updateConfigById(id: number, updates: Partial<Omit<BotConfigRecord, 'id' | 'createdAt'>>): Promise<boolean>;
58
65
  /**
59
- * 删除 Bot 配置
66
+ * 删除 Bot 配置(根据 ID)
60
67
  */
61
- deleteConfig(selfId: string): Promise<boolean>;
68
+ deleteConfigById(id: number): Promise<boolean>;
62
69
  /**
63
70
  * 切换 Bot 启用状态
64
71
  */
65
- toggleEnabled(selfId: string): Promise<boolean>;
72
+ toggleEnabled(id: number): Promise<boolean>;
73
+ /**
74
+ * 更新配置的 selfId(Bot 连接成功后调用)
75
+ */
76
+ updateSelfId(id: number, selfId: string): Promise<boolean>;
66
77
  /**
67
- * 将数据库配置转换为 BotConfig 格式
78
+ * 将数据库配置转换为 BotConfig 格式(用于启动 Bot)
68
79
  */
69
- toBotConfig(record: BotConfigRecord): BotConfig;
80
+ toBotConfig(record: BotConfigRecord): BotConfig & {
81
+ configId: number;
82
+ };
70
83
  }
package/lib/index.d.ts CHANGED
@@ -3,6 +3,14 @@ import { OneBotBot } from './bot';
3
3
  import { BaseBot } from './bot/base';
4
4
  import { PanelConfig } from './panel';
5
5
  import * as OneBot from './utils';
6
+ declare module '@koishijs/console' {
7
+ interface Events {
8
+ 'onebot-multi/config'(): {
9
+ basePath: string;
10
+ enabled: boolean;
11
+ };
12
+ }
13
+ }
6
14
  export { OneBot };
7
15
  export * from './bot';
8
16
  export * from './ws';
@@ -30,6 +38,7 @@ export declare const Config: Schema<Config>;
30
38
  export declare const name = "adapter-onebot-multi";
31
39
  export declare const inject: {
32
40
  required: string[];
41
+ optional: string[];
33
42
  };
34
43
  export declare function apply(ctx: Context, config: Config): void;
35
44
  declare module 'koishi' {