onebots 1.0.0 → 1.0.5
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/adapter-schema-presets.d.ts +8 -0
- package/lib/adapter-schema-presets.js +118 -0
- package/lib/app.d.ts +20 -0
- package/lib/app.js +711 -30
- package/lib/bin.js +2 -36
- 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 +81 -0
- package/lib/daemon.d.ts +30 -0
- package/lib/daemon.js +94 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/service-manager.d.ts +4 -0
- package/lib/service-manager.js +171 -0
- package/package.json +10 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 未在进程启动时通过 -r 加载的适配器,其 registerSchema 不会执行,
|
|
3
|
+
* Web 管理端拉取 /api/config/schema 时 adapters 会缺项,导致无法选平台、无表单项。
|
|
4
|
+
* 此处预设与各适配器 index.ts 中 registerSchema 保持一致(变更时请同步修改)。
|
|
5
|
+
*/
|
|
6
|
+
import type { Schema } from "@onebots/core";
|
|
7
|
+
export declare const ADAPTER_SCHEMA_PRESETS: Record<string, Schema>;
|
|
8
|
+
//# sourceMappingURL=adapter-schema-presets.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export const ADAPTER_SCHEMA_PRESETS = {
|
|
2
|
+
"wecom-kf": {
|
|
3
|
+
account_id: { type: "string", required: true, label: "账号标识" },
|
|
4
|
+
corp_id: { type: "string", required: true, label: "企业 ID" },
|
|
5
|
+
corp_secret: { type: "string", required: true, label: "自建应用 Secret(已授权微信客服 API)" },
|
|
6
|
+
token: { type: "string", required: true, label: "回调 Token" },
|
|
7
|
+
encoding_aes_key: { type: "string", required: true, label: "EncodingAESKey" },
|
|
8
|
+
open_kfid: { type: "string", label: "默认客服 open_kfid" },
|
|
9
|
+
agent_id: { type: "string", label: "应用 AgentId(上传临时素材时必填)" },
|
|
10
|
+
enable_sync_poll: { type: "boolean", label: "启用无 token 轮询 sync_msg(易触发频次限制)" },
|
|
11
|
+
sync_poll_interval_ms: { type: "number", label: "轮询间隔(毫秒)" },
|
|
12
|
+
cursor_store_path: { type: "string", label: "sync_msg 游标 JSON 文件路径" },
|
|
13
|
+
},
|
|
14
|
+
icqq: {
|
|
15
|
+
account_id: { type: "string", required: true, label: "QQ 号" },
|
|
16
|
+
password: { type: "string", label: "密码(可选/支持扫码)" },
|
|
17
|
+
protocol: {
|
|
18
|
+
platform: { type: "number", enum: [1, 2, 3, 4, 5, 6], default: 2, label: "登录平台" },
|
|
19
|
+
ver: { type: "string", label: "APK 版本" },
|
|
20
|
+
sign_api_addr: { type: "string", label: "签名服务器地址" },
|
|
21
|
+
data_dir: { type: "string", label: "数据目录" },
|
|
22
|
+
log_config: { type: "object", label: "log4js 配置" },
|
|
23
|
+
ignore_self: { type: "boolean", default: true, label: "过滤自己消息" },
|
|
24
|
+
resend: { type: "boolean", default: true, label: "风控分片发送" },
|
|
25
|
+
reconn_interval: { type: "number", default: 5, label: "重连间隔(秒)" },
|
|
26
|
+
cache_group_member: { type: "boolean", default: true, label: "缓存群员列表" },
|
|
27
|
+
auto_server: { type: "boolean", default: true, label: "自动选择服务器" },
|
|
28
|
+
ffmpeg_path: { type: "string", label: "ffmpeg 路径" },
|
|
29
|
+
ffprobe_path: { type: "string", label: "ffprobe 路径" },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
line: {
|
|
33
|
+
account_id: { type: "string", required: true, label: "账号标识" },
|
|
34
|
+
channel_access_token: { type: "string", required: true, label: "Channel Access Token" },
|
|
35
|
+
channel_secret: { type: "string", required: true, label: "Channel Secret" },
|
|
36
|
+
proxy: {
|
|
37
|
+
url: { type: "string", label: "代理地址" },
|
|
38
|
+
username: { type: "string", label: "代理用户名" },
|
|
39
|
+
password: { type: "string", label: "代理密码" },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
email: {
|
|
43
|
+
account_id: { type: "string", required: true, label: "账号标识" },
|
|
44
|
+
from: { type: "string", required: true, label: "发件人邮箱" },
|
|
45
|
+
fromName: { type: "string", label: "发件人名称" },
|
|
46
|
+
smtp: {
|
|
47
|
+
host: { type: "string", required: true, label: "SMTP 主机" },
|
|
48
|
+
port: { type: "number", default: 587, label: "SMTP 端口" },
|
|
49
|
+
secure: { type: "boolean", default: true, label: "TLS" },
|
|
50
|
+
requireTLS: { type: "boolean", default: true, label: "STARTTLS" },
|
|
51
|
+
user: { type: "string", required: true, label: "SMTP 用户名" },
|
|
52
|
+
password: { type: "string", required: true, label: "SMTP 密码" },
|
|
53
|
+
proxy: {
|
|
54
|
+
url: { type: "string", label: "代理地址" },
|
|
55
|
+
username: { type: "string", label: "代理用户名" },
|
|
56
|
+
password: { type: "string", label: "代理密码" },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
imap: {
|
|
60
|
+
host: { type: "string", required: true, label: "IMAP 主机" },
|
|
61
|
+
port: { type: "number", default: 993, label: "IMAP 端口" },
|
|
62
|
+
tls: { type: "boolean", default: true, label: "TLS" },
|
|
63
|
+
user: { type: "string", required: true, label: "IMAP 用户名" },
|
|
64
|
+
password: { type: "string", required: true, label: "IMAP 密码" },
|
|
65
|
+
proxy: {
|
|
66
|
+
url: { type: "string", label: "代理地址" },
|
|
67
|
+
username: { type: "string", label: "代理用户名" },
|
|
68
|
+
password: { type: "string", label: "代理密码" },
|
|
69
|
+
},
|
|
70
|
+
pollInterval: { type: "number", default: 30000, label: "轮询间隔(毫秒)" },
|
|
71
|
+
mailbox: { type: "string", default: "INBOX", label: "邮箱文件夹" },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
whatsapp: {
|
|
75
|
+
account_id: { type: "string", required: true, label: "账号标识" },
|
|
76
|
+
businessAccountId: { type: "string", required: true, label: "Business Account ID" },
|
|
77
|
+
phoneNumberId: { type: "string", required: true, label: "Phone Number ID" },
|
|
78
|
+
accessToken: { type: "string", required: true, label: "Access Token" },
|
|
79
|
+
webhookVerifyToken: { type: "string", required: true, label: "Webhook 验证令牌" },
|
|
80
|
+
apiVersion: { type: "string", default: "v21.0", label: "API 版本" },
|
|
81
|
+
proxy: {
|
|
82
|
+
url: { type: "string", label: "代理地址" },
|
|
83
|
+
username: { type: "string", label: "代理用户名" },
|
|
84
|
+
password: { type: "string", label: "代理密码" },
|
|
85
|
+
},
|
|
86
|
+
webhook: {
|
|
87
|
+
url: { type: "string", label: "Webhook URL" },
|
|
88
|
+
fields: { type: "array", label: "订阅字段" },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
zulip: {
|
|
92
|
+
account_id: { type: "string", required: true, label: "账号标识" },
|
|
93
|
+
serverUrl: { type: "string", required: true, label: "服务器地址" },
|
|
94
|
+
email: { type: "string", required: true, label: "邮箱地址" },
|
|
95
|
+
apiKey: { type: "string", required: true, label: "API Key" },
|
|
96
|
+
proxy: {
|
|
97
|
+
url: { type: "string", label: "代理地址" },
|
|
98
|
+
username: { type: "string", label: "代理用户名" },
|
|
99
|
+
password: { type: "string", label: "代理密码" },
|
|
100
|
+
},
|
|
101
|
+
websocket: {
|
|
102
|
+
enabled: { type: "boolean", default: true, label: "启用 WebSocket" },
|
|
103
|
+
reconnectInterval: { type: "number", default: 3000, label: "重连间隔(毫秒)" },
|
|
104
|
+
maxReconnectAttempts: { type: "number", default: 10, label: "最大重连次数" },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
mock: {
|
|
108
|
+
account_id: { type: "string", required: true, label: "账号标识" },
|
|
109
|
+
nickname: { type: "string", label: "用户名" },
|
|
110
|
+
avatar: { type: "string", label: "头像 URL" },
|
|
111
|
+
auto_events: { type: "boolean", label: "自动生成事件" },
|
|
112
|
+
event_interval: { type: "number", label: "事件间隔(毫秒)" },
|
|
113
|
+
latency: { type: "number", label: "模拟延迟(毫秒)" },
|
|
114
|
+
friends: { type: "array", label: "预定义好友列表" },
|
|
115
|
+
groups: { type: "array", label: "预定义群组列表" },
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=adapter-schema-presets.js.map
|
package/lib/app.d.ts
CHANGED
|
@@ -5,13 +5,33 @@ export declare class App extends BaseApp {
|
|
|
5
5
|
private logCacheFile;
|
|
6
6
|
private logWriteStream;
|
|
7
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;
|
|
8
13
|
private ptyTerminal;
|
|
9
14
|
private terminalClients;
|
|
15
|
+
private tokenManager;
|
|
10
16
|
constructor(config: App.Config);
|
|
11
17
|
private initLogCache;
|
|
12
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;
|
|
13
27
|
private cleanupLogCache;
|
|
14
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;
|
|
15
35
|
start(): Promise<void>;
|
|
16
36
|
}
|
|
17
37
|
export declare namespace App {
|