@mishap213/openclaw-channel-vk 1.0.2 → 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/index.ts +32 -9
- package/openclaw.plugin.json +28 -5
- package/package.json +21 -4
- package/setup-entry.ts +4 -3
- package/src/channel.ts +82 -13
package/index.ts
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/channel-core";
|
|
2
|
+
import { vkChannelPlugin } from "./src/channel.js";
|
|
3
3
|
|
|
4
4
|
export default defineChannelPluginEntry({
|
|
5
|
-
id:
|
|
6
|
-
name:
|
|
7
|
-
description:
|
|
8
|
-
plugin:
|
|
5
|
+
id: "vk",
|
|
6
|
+
name: "VKontakte",
|
|
7
|
+
description: "VKontakte channel plugin for OpenClaw",
|
|
8
|
+
plugin: vkChannelPlugin,
|
|
9
|
+
|
|
10
|
+
// CLI-метаданные (показываются в help, не грузят рантайм)
|
|
11
|
+
registerCliMetadata(api) {
|
|
12
|
+
api.registerCli(
|
|
13
|
+
({ program }) => {
|
|
14
|
+
program
|
|
15
|
+
.command("vk")
|
|
16
|
+
.description("VKontakte channel management");
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
descriptors: [
|
|
20
|
+
{
|
|
21
|
+
name: "vk",
|
|
22
|
+
description: "VKontakte channel management",
|
|
23
|
+
hasSubcommands: false,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// Полный рантайм (грузится только когда канал включён)
|
|
9
31
|
registerFull(api) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
32
|
+
// Здесь можно зарегистрировать HTTP-роуты для вебхуков ВК
|
|
33
|
+
// api.registerHttpRoute({ path: "/vk/webhook", ... });
|
|
34
|
+
},
|
|
35
|
+
});
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
{
|
|
2
2
|
"id": "vk",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "VKontakte messaging
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"label": "VKontakte Channel",
|
|
5
|
+
"description": "Channel plugin for VKontakte messaging platform",
|
|
6
|
+
"entry": "./index.ts",
|
|
7
|
+
"setupEntry": "./setup-entry.ts",
|
|
8
|
+
"channel": {
|
|
9
|
+
"id": "vk",
|
|
10
|
+
"label": "VKontakte",
|
|
11
|
+
"blurb": "Connect OpenClaw to VKontakte messaging."
|
|
12
|
+
},
|
|
13
|
+
"config": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"vkToken": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "VK Community Access Token",
|
|
19
|
+
"sensitive": true
|
|
20
|
+
},
|
|
21
|
+
"groupId": {
|
|
22
|
+
"type": "integer",
|
|
23
|
+
"description": "VK Group ID",
|
|
24
|
+
"default": 237153619
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": ["vkToken", "groupId"]
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mishap213/openclaw-channel-vk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "VKontakte channel plugin for OpenClaw",
|
|
6
6
|
"author": "Mikhail",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "index.ts",
|
|
9
9
|
"files": ["index.ts", "setup-entry.ts", "openclaw.plugin.json", "src/"],
|
|
10
|
-
"peerDependencies": {
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"openclaw": ">=2026.3.0"
|
|
12
|
+
},
|
|
11
13
|
"openclaw": {
|
|
12
14
|
"extensions": ["./index.ts"],
|
|
13
15
|
"setupEntry": "./setup-entry.ts",
|
|
14
|
-
"channel": {
|
|
16
|
+
"channel": {
|
|
17
|
+
"id": "vk",
|
|
18
|
+
"label": "VKontakte",
|
|
19
|
+
"blurb": "Connect OpenClaw to VKontakte messaging."
|
|
20
|
+
},
|
|
21
|
+
"compat": {
|
|
22
|
+
"pluginApi": ">=2026.3.0",
|
|
23
|
+
"minGatewayVersion": "2026.3.0"
|
|
24
|
+
},
|
|
25
|
+
"build": {
|
|
26
|
+
"openclawVersion": "2026.3.0",
|
|
27
|
+
"pluginSdkVersion": "2026.3.0"
|
|
28
|
+
}
|
|
15
29
|
},
|
|
16
|
-
"publishConfig": {
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
}
|
|
17
34
|
}
|
package/setup-entry.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { defineSetupPluginEntry } from "openclaw/plugin-sdk/channel-core";
|
|
2
|
+
import { vkChannelPlugin } from "./src/channel.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// Эта точка входа грузится при настройке, чтобы не тянуть тяжёлый рантайм
|
|
5
|
+
export default defineSetupPluginEntry(vkChannelPlugin);
|
package/src/channel.ts
CHANGED
|
@@ -1,22 +1,91 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
createChatChannelPlugin,
|
|
3
|
+
createChannelPluginBase,
|
|
4
|
+
type OpenClawConfig,
|
|
5
|
+
} from "openclaw/plugin-sdk/channel-core";
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
type ResolvedAccount = {
|
|
8
|
+
accountId: string | null;
|
|
9
|
+
vkToken: string;
|
|
10
|
+
groupId: number;
|
|
11
|
+
allowFrom: string[];
|
|
12
|
+
dmPolicy: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function resolveAccount(
|
|
16
|
+
cfg: OpenClawConfig,
|
|
17
|
+
accountId?: string | null,
|
|
18
|
+
): ResolvedAccount {
|
|
19
|
+
const section = (cfg.channels as Record<string, any>)?.["vk"];
|
|
20
|
+
const vkToken = section?.vkToken;
|
|
21
|
+
const groupId = section?.groupId;
|
|
22
|
+
|
|
23
|
+
if (!vkToken) throw new Error("vk: vkToken is required");
|
|
24
|
+
if (!groupId) throw new Error("vk: groupId is required");
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
accountId: accountId ?? null,
|
|
28
|
+
vkToken,
|
|
29
|
+
groupId,
|
|
30
|
+
allowFrom: section?.allowFrom ?? [],
|
|
31
|
+
dmPolicy: section?.dmSecurity,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const vkChannelPlugin = createChatChannelPlugin<ResolvedAccount>({
|
|
4
36
|
base: createChannelPluginBase({
|
|
5
|
-
id:
|
|
37
|
+
id: "vk",
|
|
38
|
+
setup: {
|
|
39
|
+
resolveAccount,
|
|
40
|
+
inspectAccount(cfg, accountId) {
|
|
41
|
+
const section = (cfg.channels as Record<string, any>)?.["vk"];
|
|
42
|
+
return {
|
|
43
|
+
enabled: Boolean(section?.vkToken && section?.groupId),
|
|
44
|
+
configured: Boolean(section?.vkToken && section?.groupId),
|
|
45
|
+
tokenStatus: section?.vkToken ? "available" : "missing",
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
},
|
|
6
49
|
}),
|
|
7
50
|
|
|
51
|
+
// Безопасность: кто может писать боту в ЛС
|
|
52
|
+
security: {
|
|
53
|
+
dm: {
|
|
54
|
+
channelKey: "vk",
|
|
55
|
+
resolvePolicy: (account) => account.dmPolicy ?? "allowlist",
|
|
56
|
+
resolveAllowFrom: (account) => account.allowFrom,
|
|
57
|
+
defaultPolicy: "allowlist",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// Паринг: код подтверждения для новых контактов
|
|
62
|
+
pairing: {
|
|
63
|
+
text: {
|
|
64
|
+
idLabel: "VK user ID",
|
|
65
|
+
message: "Отправьте этот код для подтверждения:",
|
|
66
|
+
notify: async ({ target, code }) => {
|
|
67
|
+
// Здесь будет отправка через vk-io
|
|
68
|
+
console.log(`[VK] Pairing code ${code} for ${target}`);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// Поток ответов: как доставлять ответы
|
|
74
|
+
threading: { topLevelReplyToMode: "reply" },
|
|
75
|
+
|
|
76
|
+
// Отправка сообщений в ВК
|
|
8
77
|
outbound: {
|
|
9
78
|
attachedResults: {
|
|
10
79
|
sendText: async (params) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
80
|
+
// Здесь будет реальный вызов vk-io
|
|
81
|
+
console.log(`[VK] Send to ${params.to}: ${params.text}`);
|
|
82
|
+
return { messageId: `vk_${Date.now()}` };
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
base: {
|
|
86
|
+
sendMedia: async (params) => {
|
|
87
|
+
console.log(`[VK] Send media to ${params.to}`);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
15
90
|
},
|
|
16
|
-
|
|
17
|
-
activate: async (config) => {
|
|
18
|
-
console.log(\"✅ VK PLUGIN: activate() called\", config);
|
|
19
|
-
}
|
|
20
91
|
});
|
|
21
|
-
|
|
22
|
-
export { vkChatPlugin };
|