@kirigaya/openclaw-onebot 1.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -0
  3. package/dist/channel.d.ts +100 -0
  4. package/dist/channel.js +173 -0
  5. package/dist/config.d.ts +6 -0
  6. package/dist/config.js +62 -0
  7. package/dist/connection.d.ts +94 -0
  8. package/dist/connection.js +426 -0
  9. package/dist/debug-log.d.ts +7 -0
  10. package/dist/debug-log.js +24 -0
  11. package/dist/gateway-proxy.d.ts +8 -0
  12. package/dist/gateway-proxy.js +36 -0
  13. package/dist/handlers/group-increase.d.ts +21 -0
  14. package/dist/handlers/group-increase.js +95 -0
  15. package/dist/handlers/process-inbound.d.ts +11 -0
  16. package/dist/handlers/process-inbound.js +224 -0
  17. package/dist/index.d.ts +11 -0
  18. package/dist/index.js +33 -0
  19. package/dist/load-script.d.ts +5 -0
  20. package/dist/load-script.js +22 -0
  21. package/dist/message.d.ts +6 -0
  22. package/dist/message.js +24 -0
  23. package/dist/reply-context.d.ts +12 -0
  24. package/dist/reply-context.js +33 -0
  25. package/dist/scheduler.d.ts +19 -0
  26. package/dist/scheduler.js +70 -0
  27. package/dist/sdk.d.ts +9 -0
  28. package/dist/sdk.js +36 -0
  29. package/dist/send.d.ts +23 -0
  30. package/dist/send.js +98 -0
  31. package/dist/service.d.ts +4 -0
  32. package/dist/service.js +71 -0
  33. package/dist/setup.d.ts +1 -0
  34. package/dist/setup.js +65 -0
  35. package/dist/tools.d.ts +18 -0
  36. package/dist/tools.js +188 -0
  37. package/dist/types.d.ts +28 -0
  38. package/dist/types.js +4 -0
  39. package/openclaw.plugin.json +72 -0
  40. package/package.json +74 -0
  41. package/skills/onebot-ops/SKILL.md +61 -0
  42. package/skills/onebot-ops/config.md +55 -0
  43. package/skills/onebot-ops/receive.md +85 -0
  44. package/skills/onebot-ops/send.md +39 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LSTM-Kirigaya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # openclaw-onebot
2
+
3
+ 将 **OneBot v11 协议**(QQ/Lagrange.Core、go-cqhttp 等)接入 [OpenClaw](https://openclaw.ai) Gateway 的渠道插件。
4
+
5
+ [![npm version](https://img.shields.io/npm/v/openclaw-onebot.svg)](https://www.npmjs.com/package/openclaw-onebot)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
+
8
+ ## 功能
9
+
10
+ - ✅ 私聊:所有消息 AI 都会回复
11
+ - ✅ 群聊:仅当用户 @ 机器人时回复(可配置)
12
+ - ✅ 正向 / 反向 WebSocket 连接
13
+ - ✅ TUI 配置向导:`openclaw onebot setup`
14
+ - ✅ 新成员入群欢迎
15
+ - ✅ 通过 `openclaw message send` CLI 发送(无 Agent 工具,降低 token 消耗)
16
+ - ✅ **内置定时任务**:配置 `cronJobs` 后,在指定时间直接执行脚本并推送到群聊,**无需 AI 介入**
17
+
18
+ ## 安装
19
+
20
+ ```bash
21
+ openclaw plugins install openclaw-onebot
22
+ ```
23
+
24
+ 或从 GitHub 安装:
25
+
26
+ ```bash
27
+ openclaw plugins install https://github.com/LSTM-Kirigaya/openclaw-onebot.git
28
+ ```
29
+
30
+ ## 配置
31
+
32
+ ### 方式一:TUI 向导(推荐)
33
+
34
+ ```bash
35
+ openclaw onebot setup
36
+ ```
37
+
38
+ 交互式输入:连接类型、主机、端口、Access Token。
39
+
40
+ ### 方式二:手动编辑 `~/.openclaw/openclaw.json`
41
+
42
+ ```json
43
+ {
44
+ "channels": {
45
+ "onebot": {
46
+ "type": "forward-websocket",
47
+ "host": "127.0.0.1",
48
+ "port": 3001,
49
+ "accessToken": "可选",
50
+ "enabled": true,
51
+ "requireMention": true,
52
+ "groupIncrease": {
53
+ "enabled": true,
54
+ "message": "欢迎 {userId} 加入群聊!"
55
+ },
56
+ "cronJobs": [
57
+ {
58
+ "name": "每日科技新闻",
59
+ "cron": "0 8 * * *",
60
+ "timezone": "Asia/Shanghai",
61
+ "script": "./Tiphareth/src/openclaw/cron/daily-news.ts",
62
+ "groupIds": [782833642]
63
+ },
64
+ {
65
+ "name": "每日GitHub热榜",
66
+ "cron": "0 9 * * *",
67
+ "timezone": "Asia/Shanghai",
68
+ "script": "./Tiphareth/src/openclaw/cron/github-trending.ts",
69
+ "groupIds": [782833642]
70
+ }
71
+ ]
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ **说明**:`cronJobs` 为内置定时任务,在指定时间**直接执行脚本**并推送到群聊,不经过 Agent,无 token 消耗。脚本路径相对 `process.cwd()`(通常为启动 OpenClaw 时的目录),请确保从项目根目录启动。
78
+
79
+ ### 连接类型
80
+
81
+ | 类型 | 说明 |
82
+ |------|------|
83
+ | `forward-websocket` | 插件主动连接 OneBot(go-cqhttp、Lagrange.Core 正向 WS) |
84
+ | `backward-websocket` | 插件作为服务端,OneBot 连接过来 |
85
+
86
+ ### 环境变量
87
+
88
+ 可替代配置文件,适用于 Lagrange 等:
89
+
90
+ | 变量 | 说明 |
91
+ |------|------|
92
+ | `LAGRANGE_WS_TYPE` | forward-websocket / backward-websocket |
93
+ | `LAGRANGE_WS_HOST` | 主机地址 |
94
+ | `LAGRANGE_WS_PORT` | 端口 |
95
+ | `LAGRANGE_WS_ACCESS_TOKEN` | 访问令牌 |
96
+
97
+ ## 使用
98
+
99
+ 1. 安装并配置
100
+ 2. 重启 Gateway:`openclaw gateway restart`
101
+ 3. 在 QQ 私聊或群聊中发消息(群聊需 @ 机器人)
102
+
103
+ ## 主动发送消息
104
+
105
+ 通过 `openclaw message send` CLI(无需 Agent 工具):
106
+
107
+ ```bash
108
+ # 发送文本
109
+ openclaw message send --channel onebot --target user:123456789 --message "你好"
110
+
111
+ # 发送图片
112
+ openclaw message send --channel onebot --target group:987654321 --media "file:///path/to/image.png"
113
+ ```
114
+
115
+ `--target` 格式:`user:QQ号` 或 `group:群号`。回复场景由 deliver 自动投递,Agent 输出 text/mediaUrl 即会送达。
116
+
117
+ ## 测试连接
118
+
119
+ 项目内提供测试脚本(需 `.env` 或环境变量):
120
+
121
+ ```bash
122
+ cd openclaw-onebot
123
+ npm run test:connect
124
+ ```
125
+
126
+ ## 协议参考
127
+
128
+ - [OneBot 11](https://github.com/botuniverse/onebot-11)
129
+ - [go-cqhttp](https://docs.go-cqhttp.org/)
130
+ - [Lagrange.Core](https://github.com/LSTM-Kirigaya/Lagrange.Core)
131
+
132
+ ## License
133
+
134
+ MIT © [LSTM-Kirigaya](https://github.com/LSTM-Kirigaya)
@@ -0,0 +1,100 @@
1
+ /**
2
+ * OneBot Channel 插件定义
3
+ * 仿照 openclaw-feishu channel.ts 结构,接入 OneBot v11 协议(QQ/Lagrange.Core/go-cqhttp)
4
+ *
5
+ * 对应 Lagrange.onebot context.ts 的 API:
6
+ * - sendPrivateMsg / sendGroupMsg / sendMsg
7
+ * - sendGroupImage / sendPrivateImage(图片)
8
+ * - deleteMsg / getMsg / getGroupMsgHistory
9
+ * - uploadGroupFile / uploadPrivateFile
10
+ */
11
+ declare function normalizeOneBotMessagingTarget(raw: string): string | undefined;
12
+ export declare const OneBotChannelPlugin: {
13
+ id: string;
14
+ meta: {
15
+ id: string;
16
+ label: string;
17
+ selectionLabel: string;
18
+ docsPath: string;
19
+ blurb: string;
20
+ aliases: string[];
21
+ docsLabel: string;
22
+ order: number;
23
+ };
24
+ capabilities: {
25
+ chatTypes: readonly ["direct", "group"];
26
+ media: boolean;
27
+ reactions: boolean;
28
+ threads: boolean;
29
+ polls: boolean;
30
+ };
31
+ reload: {
32
+ configPrefixes: readonly ["channels.onebot"];
33
+ };
34
+ config: {
35
+ listAccountIds: (cfg: any) => string[];
36
+ resolveAccount: (cfg: any, accountId?: string) => any;
37
+ };
38
+ groups: {
39
+ resolveRequireMention: () => boolean;
40
+ };
41
+ messaging: {
42
+ normalizeTarget: typeof normalizeOneBotMessagingTarget;
43
+ targetResolver: {
44
+ looksLikeId: (raw: string) => boolean;
45
+ hint: string;
46
+ };
47
+ };
48
+ outbound: {
49
+ deliveryMode: "direct";
50
+ chunker: (text: string, limit: number) => string[];
51
+ chunkerMode: "text";
52
+ textChunkLimit: number;
53
+ resolveTarget: ({ to }: {
54
+ to?: string;
55
+ }) => {
56
+ ok: boolean;
57
+ error: Error;
58
+ to?: undefined;
59
+ } | {
60
+ ok: boolean;
61
+ to: string;
62
+ error?: undefined;
63
+ };
64
+ sendText: ({ to, text, accountId, cfg }: {
65
+ to: string;
66
+ text: string;
67
+ accountId?: string;
68
+ cfg?: any;
69
+ }) => Promise<{
70
+ channel: string;
71
+ ok: boolean;
72
+ messageId: string;
73
+ error: Error;
74
+ } | {
75
+ channel: string;
76
+ ok: boolean;
77
+ messageId: string;
78
+ error?: undefined;
79
+ }>;
80
+ sendMedia: (params: {
81
+ to: string;
82
+ text?: string;
83
+ mediaUrl?: string;
84
+ media?: string;
85
+ accountId?: string;
86
+ cfg?: any;
87
+ }) => Promise<{
88
+ channel: string;
89
+ ok: boolean;
90
+ messageId: string;
91
+ error: Error;
92
+ } | {
93
+ channel: string;
94
+ ok: boolean;
95
+ messageId: string;
96
+ error?: undefined;
97
+ }>;
98
+ };
99
+ };
100
+ export {};
@@ -0,0 +1,173 @@
1
+ /**
2
+ * OneBot Channel 插件定义
3
+ * 仿照 openclaw-feishu channel.ts 结构,接入 OneBot v11 协议(QQ/Lagrange.Core/go-cqhttp)
4
+ *
5
+ * 对应 Lagrange.onebot context.ts 的 API:
6
+ * - sendPrivateMsg / sendGroupMsg / sendMsg
7
+ * - sendGroupImage / sendPrivateImage(图片)
8
+ * - deleteMsg / getMsg / getGroupMsgHistory
9
+ * - uploadGroupFile / uploadPrivateFile
10
+ */
11
+ import { getOneBotConfig, listAccountIds } from "./config.js";
12
+ import { sendTextMessage, sendMediaMessage } from "./send.js";
13
+ const meta = {
14
+ id: "onebot",
15
+ label: "OneBot",
16
+ selectionLabel: "OneBot (QQ/Lagrange)",
17
+ docsPath: "/channels/onebot",
18
+ docsLabel: "onebot",
19
+ blurb: "OneBot v11 protocol via WebSocket (go-cqhttp, Lagrange.Core)",
20
+ aliases: ["qq", "lagrange", "cqhttp"],
21
+ order: 85,
22
+ };
23
+ function normalizeOneBotMessagingTarget(raw) {
24
+ const trimmed = raw?.trim();
25
+ if (!trimmed)
26
+ return undefined;
27
+ return trimmed.replace(/^(onebot|qq|lagrange):/i, "").trim();
28
+ }
29
+ function parseTarget(to) {
30
+ const t = to.replace(/^(onebot|qq|lagrange):/i, "").trim();
31
+ if (!t)
32
+ return null;
33
+ if (t.startsWith("group:")) {
34
+ const id = parseInt(t.slice(6), 10);
35
+ if (isNaN(id))
36
+ return null;
37
+ return { type: "group", id };
38
+ }
39
+ const rawId = t.replace(/^user:/, "");
40
+ const id = parseInt(rawId, 10);
41
+ if (isNaN(id))
42
+ return null;
43
+ if (rawId === t && !t.includes(":")) {
44
+ return { type: id > 100000000 ? "user" : "group", id };
45
+ }
46
+ return { type: "user", id };
47
+ }
48
+ export const OneBotChannelPlugin = {
49
+ id: "onebot",
50
+ meta: {
51
+ ...meta,
52
+ id: meta.id,
53
+ label: meta.label,
54
+ selectionLabel: meta.selectionLabel,
55
+ docsPath: meta.docsPath,
56
+ blurb: meta.blurb,
57
+ aliases: meta.aliases,
58
+ },
59
+ capabilities: {
60
+ chatTypes: ["direct", "group"],
61
+ media: true,
62
+ reactions: false,
63
+ threads: false,
64
+ polls: false,
65
+ },
66
+ reload: { configPrefixes: ["channels.onebot"] },
67
+ config: {
68
+ listAccountIds: (cfg) => listAccountIds(cfg),
69
+ resolveAccount: (cfg, accountId) => {
70
+ const id = accountId ?? "default";
71
+ const acc = cfg?.channels?.onebot?.accounts?.[id];
72
+ if (acc)
73
+ return { accountId: id, ...acc };
74
+ const ch = cfg?.channels?.onebot;
75
+ if (ch?.host)
76
+ return { accountId: id, ...ch };
77
+ return { accountId: id };
78
+ },
79
+ },
80
+ groups: {
81
+ resolveRequireMention: () => true,
82
+ },
83
+ messaging: {
84
+ normalizeTarget: normalizeOneBotMessagingTarget,
85
+ targetResolver: {
86
+ looksLikeId: (raw) => {
87
+ const trimmed = raw.trim();
88
+ if (!trimmed)
89
+ return false;
90
+ return /^group:\d+$/.test(trimmed) || /^user:\d+$/.test(trimmed) || /^\d{6,}$/.test(trimmed);
91
+ },
92
+ hint: "user:<QQ号> 或 group:<群号>",
93
+ },
94
+ },
95
+ outbound: {
96
+ deliveryMode: "direct",
97
+ chunker: (text, limit) => {
98
+ if (!text)
99
+ return [];
100
+ if (limit <= 0 || text.length <= limit)
101
+ return [text];
102
+ const chunks = [];
103
+ let remaining = text;
104
+ while (remaining.length > limit) {
105
+ const window = remaining.slice(0, limit);
106
+ const lastNewline = window.lastIndexOf("\n");
107
+ const lastSpace = window.lastIndexOf(" ");
108
+ let breakIdx = lastNewline > 0 ? lastNewline : lastSpace;
109
+ if (breakIdx <= 0)
110
+ breakIdx = limit;
111
+ const rawChunk = remaining.slice(0, breakIdx);
112
+ const chunk = rawChunk.trimEnd();
113
+ if (chunk.length > 0)
114
+ chunks.push(chunk);
115
+ const brokeOnSeparator = breakIdx < remaining.length && /\s/.test(remaining[breakIdx]);
116
+ const nextStart = Math.min(remaining.length, breakIdx + (brokeOnSeparator ? 1 : 0));
117
+ remaining = remaining.slice(nextStart).trimStart();
118
+ }
119
+ if (remaining.length)
120
+ chunks.push(remaining);
121
+ return chunks;
122
+ },
123
+ chunkerMode: "text",
124
+ textChunkLimit: 4000,
125
+ resolveTarget: ({ to }) => {
126
+ const t = to?.trim();
127
+ if (!t)
128
+ return { ok: false, error: new Error("OneBot requires --to <user_id|group_id>") };
129
+ return { ok: true, to: t };
130
+ },
131
+ sendText: async ({ to, text, accountId, cfg }) => {
132
+ const api = cfg ? { config: cfg } : globalThis.__onebotApi;
133
+ const config = getOneBotConfig(api, accountId);
134
+ if (!config) {
135
+ return { channel: "onebot", ok: false, messageId: "", error: new Error("OneBot not configured") };
136
+ }
137
+ const getConfig = () => getOneBotConfig(api, accountId);
138
+ try {
139
+ const result = await sendTextMessage(to, text, getConfig);
140
+ if (!result.ok) {
141
+ return { channel: "onebot", ok: false, messageId: "", error: new Error(result.error) };
142
+ }
143
+ return { channel: "onebot", ok: true, messageId: result.messageId ?? "" };
144
+ }
145
+ catch (e) {
146
+ return { channel: "onebot", ok: false, messageId: "", error: e instanceof Error ? e : new Error(String(e)) };
147
+ }
148
+ },
149
+ sendMedia: async (params) => {
150
+ const { to, text, accountId, cfg } = params;
151
+ const mediaUrl = params.mediaUrl ?? params.media;
152
+ const api = cfg ? { config: cfg } : globalThis.__onebotApi;
153
+ const config = getOneBotConfig(api, accountId);
154
+ if (!config) {
155
+ return { channel: "onebot", ok: false, messageId: "", error: new Error("OneBot not configured") };
156
+ }
157
+ if (!mediaUrl?.trim()) {
158
+ return { channel: "onebot", ok: false, messageId: "", error: new Error("mediaUrl is required") };
159
+ }
160
+ const getConfig = () => getOneBotConfig(api, accountId);
161
+ try {
162
+ const result = await sendMediaMessage(to, mediaUrl, text, getConfig);
163
+ if (!result.ok) {
164
+ return { channel: "onebot", ok: false, messageId: "", error: new Error(result.error) };
165
+ }
166
+ return { channel: "onebot", ok: true, messageId: result.messageId ?? "" };
167
+ }
168
+ catch (e) {
169
+ return { channel: "onebot", ok: false, messageId: "", error: e instanceof Error ? e : new Error(String(e)) };
170
+ }
171
+ },
172
+ },
173
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * OneBot 配置解析
3
+ */
4
+ import type { OneBotAccountConfig } from "./types.js";
5
+ export declare function getOneBotConfig(api: any, accountId?: string): OneBotAccountConfig | null;
6
+ export declare function listAccountIds(apiOrCfg: any): string[];
package/dist/config.js ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * OneBot 配置解析
3
+ */
4
+ export function getOneBotConfig(api, accountId) {
5
+ const cfg = api?.config ?? globalThis.__onebotGatewayConfig;
6
+ const id = accountId ?? "default";
7
+ const channel = cfg?.channels?.onebot;
8
+ const account = channel?.accounts?.[id];
9
+ if (account) {
10
+ const { type, host, port, accessToken, path } = account;
11
+ if (host && port) {
12
+ return {
13
+ accountId: id,
14
+ type: type ?? "forward-websocket",
15
+ host,
16
+ port,
17
+ accessToken,
18
+ path: path ?? "/onebot/v11/ws",
19
+ enabled: account.enabled !== false,
20
+ };
21
+ }
22
+ }
23
+ if (channel?.host && channel?.port) {
24
+ return {
25
+ accountId: id,
26
+ type: channel.type ?? "forward-websocket",
27
+ host: channel.host,
28
+ port: channel.port,
29
+ accessToken: channel.accessToken,
30
+ path: channel.path ?? "/onebot/v11/ws",
31
+ };
32
+ }
33
+ const type = process.env.LAGRANGE_WS_TYPE;
34
+ const host = process.env.LAGRANGE_WS_HOST;
35
+ const portStr = process.env.LAGRANGE_WS_PORT;
36
+ const accessToken = process.env.LAGRANGE_WS_ACCESS_TOKEN;
37
+ const path = process.env.LAGRANGE_WS_PATH ?? "/onebot/v11/ws";
38
+ if (host && portStr) {
39
+ const port = parseInt(portStr, 10);
40
+ if (Number.isFinite(port)) {
41
+ return {
42
+ accountId: id,
43
+ type: type === "backward-websocket" ? "backward-websocket" : "forward-websocket",
44
+ host,
45
+ port,
46
+ accessToken: accessToken || undefined,
47
+ path,
48
+ };
49
+ }
50
+ }
51
+ return null;
52
+ }
53
+ export function listAccountIds(apiOrCfg) {
54
+ const cfg = apiOrCfg?.config ?? apiOrCfg ?? globalThis.__onebotGatewayConfig;
55
+ const accounts = cfg?.channels?.onebot?.accounts;
56
+ if (accounts && Object.keys(accounts).length > 0) {
57
+ return Object.keys(accounts);
58
+ }
59
+ if (cfg?.channels?.onebot?.host)
60
+ return ["default"];
61
+ return [];
62
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * OneBot WebSocket 连接与 API 调用
3
+ *
4
+ * 图片消息:网络 URL 会先下载到本地再发送(兼容 Lagrange.Core retcode 1200),
5
+ * 并定期清理临时文件。
6
+ */
7
+ import WebSocket from "ws";
8
+ import type { OneBotAccountConfig } from "./types.js";
9
+ /** 启动临时图片定期清理(每小时执行一次) */
10
+ export declare function startImageTempCleanup(): void;
11
+ /** 停止临时图片定期清理 */
12
+ export declare function stopImageTempCleanup(): void;
13
+ export declare function handleEchoResponse(payload: any): boolean;
14
+ export declare function getWs(): WebSocket | null;
15
+ /** 等待 WebSocket 连接就绪(service 启动后异步建立连接,发送前需先等待) */
16
+ export declare function waitForConnection(timeoutMs?: number): Promise<WebSocket>;
17
+ /**
18
+ * 确保有可用的 WebSocket 连接。当 service 未启动时,
19
+ * forward-websocket 模式直接建立连接(message send 可独立运行);
20
+ * backward-websocket 模式需等待 gateway 的 service 建立连接。
21
+ */
22
+ export declare function ensureConnection(getConfig: () => OneBotAccountConfig | null, timeoutMs?: number): Promise<WebSocket>;
23
+ export declare function sendPrivateMsg(userId: number, text: string, getConfig?: () => OneBotAccountConfig | null): Promise<number | undefined>;
24
+ export declare function sendGroupMsg(groupId: number, text: string, getConfig?: () => OneBotAccountConfig | null): Promise<number | undefined>;
25
+ export declare function sendGroupImage(groupId: number, image: string, log?: {
26
+ info?: (s: string) => void;
27
+ warn?: (s: string) => void;
28
+ }, getConfig?: () => OneBotAccountConfig | null): Promise<number | undefined>;
29
+ export declare function sendPrivateImage(userId: number, image: string, log?: {
30
+ info?: (s: string) => void;
31
+ warn?: (s: string) => void;
32
+ }, getConfig?: () => OneBotAccountConfig | null): Promise<number | undefined>;
33
+ export declare function uploadGroupFile(groupId: number, file: string, name: string): Promise<void>;
34
+ export declare function uploadPrivateFile(userId: number, file: string, name: string): Promise<void>;
35
+ /** 撤回消息 */
36
+ export declare function deleteMsg(messageId: number): Promise<void>;
37
+ /**
38
+ * 对消息进行表情回应(Lagrange/QQ NT 扩展 API)
39
+ * @param message_id 需要回应的消息 ID(用户发送的消息)
40
+ * @param emoji_id 表情 ID,1 通常为点赞
41
+ * @param is_set true 添加,false 取消
42
+ */
43
+ export declare function setMsgEmojiLike(message_id: number, emoji_id: number, is_set?: boolean): Promise<void>;
44
+ /** 获取陌生人信息(含 nickname) */
45
+ export declare function getStrangerInfo(userId: number): Promise<{
46
+ nickname: string;
47
+ } | null>;
48
+ /** 获取群成员信息(含 nickname、card) */
49
+ export declare function getGroupMemberInfo(groupId: number, userId: number): Promise<{
50
+ nickname: string;
51
+ card: string;
52
+ } | null>;
53
+ /** 获取群信息(含 group_name) */
54
+ export declare function getGroupInfo(groupId: number): Promise<{
55
+ group_name: string;
56
+ } | null>;
57
+ /** QQ 头像 URL,s=640 为常用尺寸 */
58
+ export declare function getAvatarUrl(userId: number, size?: number): string;
59
+ /** 获取单条消息(需 OneBot 实现支持) */
60
+ export declare function getMsg(messageId: number): Promise<{
61
+ time: number;
62
+ message_type: string;
63
+ message_id: number;
64
+ real_id: number;
65
+ sender: {
66
+ user_id?: number;
67
+ nickname?: string;
68
+ };
69
+ message: string | unknown[];
70
+ } | null>;
71
+ /**
72
+ * 获取群聊历史消息(Lagrange.Core 扩展 API,go-cqhttp 等可能不支持)
73
+ * @param groupId 群号
74
+ * @param opts message_seq 起始序号;message_id 起始消息 ID;count 数量
75
+ */
76
+ export declare function getGroupMsgHistory(groupId: number, opts?: {
77
+ message_seq?: number;
78
+ message_id?: number;
79
+ count: number;
80
+ }): Promise<Array<{
81
+ time: number;
82
+ message_type: string;
83
+ message_id: number;
84
+ real_id: number;
85
+ sender: {
86
+ user_id?: number;
87
+ nickname?: string;
88
+ };
89
+ message: string | unknown[];
90
+ }>>;
91
+ export declare function connectForward(config: OneBotAccountConfig): Promise<WebSocket>;
92
+ export declare function createServerAndWait(config: OneBotAccountConfig): Promise<WebSocket>;
93
+ export declare function setWs(socket: WebSocket | null): void;
94
+ export declare function stopConnection(): void;