onebots 0.5.1 → 1.0.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/README.md +6 -6
- package/lib/app.d.ts +35 -7
- package/lib/app.js +1092 -63
- package/lib/bin.js +2 -48
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +293 -0
- package/lib/config-schema.d.ts +9 -0
- package/lib/config-schema.js +78 -0
- package/lib/daemon.d.ts +30 -0
- package/lib/daemon.js +94 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/service-manager.d.ts +4 -0
- package/lib/service-manager.js +171 -0
- package/package.json +13 -5
- package/lib/utils.d.ts +0 -2
- package/lib/utils.js +0 -11
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# onebots
|
|
2
2
|
|
|
3
|
-
多平台多协议的机器人应用启动器 -
|
|
3
|
+
多平台多协议的机器人应用启动器 - onebots 主应用包
|
|
4
4
|
|
|
5
5
|
## 简介
|
|
6
6
|
|
|
7
|
-
`onebots` 是
|
|
7
|
+
`onebots` 是 onebots 框架的主应用包,提供了完整的应用层功能,包括配置管理、适配器加载、协议注册等。它基于 `@onebots/core` 核心库,为开发者提供开箱即用的机器人应用解决方案。
|
|
8
8
|
|
|
9
9
|
## 特性
|
|
10
10
|
|
|
@@ -136,7 +136,7 @@ onebots [options]
|
|
|
136
136
|
|
|
137
137
|
### 配置文件结构
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
onebots 使用 YAML 格式的配置文件,采用**账号标识 + 协议配置**的方式:
|
|
140
140
|
|
|
141
141
|
```yaml
|
|
142
142
|
# 全局配置
|
|
@@ -339,7 +339,7 @@ namespace App {
|
|
|
339
339
|
|
|
340
340
|
### 自动加载
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
onebots 会自动尝试加载以下格式的包:
|
|
343
343
|
|
|
344
344
|
**适配器:**
|
|
345
345
|
- `@onebots/adapter-{platform}`
|
|
@@ -388,7 +388,7 @@ pnpm start
|
|
|
388
388
|
|
|
389
389
|
- [@onebots/protocol-onebot-v11](../protocol-onebot-v11) - OneBot V11 协议
|
|
390
390
|
- [@onebots/protocol-onebot-v12](../protocol-onebot-v12) - OneBot V12 协议
|
|
391
|
-
- [@onebots/protocol-satori](../protocol-satori) - Satori 协议
|
|
391
|
+
- [@onebots/protocol-satori-v1](../protocol-satori) - Satori 协议
|
|
392
392
|
- [@onebots/protocol-milky-v1](../protocol-milky-v1) - Milky V1 协议
|
|
393
393
|
|
|
394
394
|
## 示例项目
|
|
@@ -405,5 +405,5 @@ MIT License - 查看 [LICENSE](../../LICENSE) 文件了解详情
|
|
|
405
405
|
|
|
406
406
|
## 相关链接
|
|
407
407
|
|
|
408
|
-
- [
|
|
408
|
+
- [onebots 文档](../../docs)
|
|
409
409
|
- [GitHub 仓库](https://github.com/lc-cn/onebots)
|
package/lib/app.d.ts
CHANGED
|
@@ -1,18 +1,46 @@
|
|
|
1
|
-
import { BaseApp, Protocol
|
|
1
|
+
import { BaseApp, Protocol } from "@onebots/core";
|
|
2
|
+
import type { WsServer } from "@onebots/core";
|
|
2
3
|
export declare class App extends BaseApp {
|
|
4
|
+
ws: WsServer;
|
|
5
|
+
private logCacheFile;
|
|
6
|
+
private logWriteStream;
|
|
7
|
+
private logClients;
|
|
8
|
+
private verificationClients;
|
|
9
|
+
/** 待处理验证请求(Web 离线时也可稍后拉取完成),key: platform:account_id */
|
|
10
|
+
private pendingVerifications;
|
|
11
|
+
private static readonly VERIFICATION_TTL_MS;
|
|
12
|
+
private static readonly MAX_PENDING_VERIFICATIONS;
|
|
13
|
+
private ptyTerminal;
|
|
14
|
+
private terminalClients;
|
|
15
|
+
private tokenManager;
|
|
3
16
|
constructor(config: App.Config);
|
|
17
|
+
private initLogCache;
|
|
18
|
+
private broadcastLog;
|
|
19
|
+
/** 将验证请求推送给所有已连接的 verification SSE 客户端 */
|
|
20
|
+
private broadcastVerification;
|
|
21
|
+
/** 存储待处理验证并广播(Web 离线时也会持久化,用户稍后打开页面可拉取完成);超出上限时剔除最旧的;key 含 type 以便同一账号同时存在 device 与 sms */
|
|
22
|
+
private storeAndBroadcastVerification;
|
|
23
|
+
/** 返回未过期的待处理验证列表(用于 GET /api/verification/pending) */
|
|
24
|
+
private getPendingVerificationList;
|
|
25
|
+
/** 订阅适配器的 verification:request,用于推送到 Web 并持久化待处理列表 */
|
|
26
|
+
protected onAdapterCreated(adapter: import("@onebots/core").Adapter): void;
|
|
27
|
+
private cleanupLogCache;
|
|
28
|
+
private cacheLog;
|
|
29
|
+
/** 将当前配置与整个 data 目录备份到 HF Space 仓库(需 HF_TOKEN、HF_REPO_ID) */
|
|
30
|
+
private backupDataToHf;
|
|
31
|
+
/**
|
|
32
|
+
* 站点静态文件变更后:若配置了 HF_TOKEN + HF_REPO_ID(如 Hugging Face Space),则再次打包整个配置目录并提交到仓库,持久化 static 等文件
|
|
33
|
+
*/
|
|
34
|
+
private backupDataDirToHfAfterStaticChange;
|
|
35
|
+
start(): Promise<void>;
|
|
4
36
|
}
|
|
5
37
|
export declare namespace App {
|
|
6
38
|
interface Config extends BaseApp.Config {
|
|
7
39
|
}
|
|
8
40
|
const defaultConfig: Config;
|
|
9
41
|
function registerGeneral<K extends keyof Protocol.Configs>(key: K, config: Protocol.Config<Protocol.Configs[K]>): void;
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
function registerProtocol(name: string, version?: string): any;
|
|
13
|
-
function registerProtocol(name: string, factory: Protocol.Factory, version?: string): any;
|
|
14
|
-
function loadAdapterFactory(platform: string): Promise<Adapter.Factory>;
|
|
15
|
-
function loadProtocolFactory(name: string, version?: string): Promise<Protocol.Factory>;
|
|
42
|
+
function loadAdapterFactory(platform: string, maybeNames?: string[]): Promise<boolean>;
|
|
43
|
+
function loadProtocolFactory(name: string, maybeNames?: string[]): Promise<boolean>;
|
|
16
44
|
}
|
|
17
45
|
export declare function createOnebots(config?: BaseApp.Config | string): App;
|
|
18
46
|
export declare function defineConfig(config: BaseApp.Config): BaseApp.Config;
|