koishi-plugin-dynamic-bot 0.0.0-dev → 0.0.3
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/dbk/avatar.d.ts +2 -0
- package/lib/dbk/bots.d.ts +24 -0
- package/lib/dbk/codec.d.ts +9 -0
- package/lib/dbk/error.d.ts +5 -0
- package/lib/dbk/gateway.d.ts +32 -0
- package/lib/dbk/get-target.d.ts +3 -0
- package/lib/dbk/handlers.d.ts +3 -0
- package/lib/dbk/list-targets.d.ts +3 -0
- package/lib/dbk/protocol.d.ts +71 -0
- package/lib/dbk/recall.d.ts +3 -0
- package/lib/dbk/send.d.ts +16 -0
- package/lib/dbk/session.d.ts +44 -0
- package/lib/dbk/socket.d.ts +17 -0
- package/lib/dbk/version.d.ts +1 -0
- package/lib/gen/dbk/v1/common_pb.d.ts +187 -0
- package/lib/gen/dbk/v1/frame_pb.d.ts +88 -0
- package/lib/gen/dbk/v1/rpc_pb.d.ts +717 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.js +1942 -0
- package/package.json +22 -4
- package/src/dbk/version.ts +27 -2
- package/AGENTS.md +0 -6
package/package.json
CHANGED
|
@@ -4,20 +4,32 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/incubator4/dynamic-bot-koishi"
|
|
6
6
|
},
|
|
7
|
-
"
|
|
7
|
+
"type": "module",
|
|
8
|
+
"version": "0.0.3",
|
|
8
9
|
"license": "Apache-2.0",
|
|
9
10
|
"contributors": [
|
|
10
11
|
"AresWang <incubator4@outlook.com>"
|
|
11
12
|
],
|
|
12
13
|
"description": "dynamic-bot Koishi gateway (DBK)",
|
|
13
|
-
"main": "
|
|
14
|
-
"types": "
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"src"
|
|
19
|
+
],
|
|
15
20
|
"peerDependencies": {
|
|
16
21
|
"koishi": "^4.18.7"
|
|
17
22
|
},
|
|
18
23
|
"dependencies": {
|
|
19
24
|
"@bufbuild/protobuf": "^2.12.1"
|
|
20
25
|
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@koishijs/plugin-http": "^0.6.3",
|
|
28
|
+
"@koishijs/plugin-server": "^3.2.4",
|
|
29
|
+
"@types/node": "^24.5.2",
|
|
30
|
+
"esbuild": "^0.23.1",
|
|
31
|
+
"typescript": "^5.9.2"
|
|
32
|
+
},
|
|
21
33
|
"koishi": {
|
|
22
34
|
"description": {
|
|
23
35
|
"zh": "将 Koishi 已连接账号作为 dynamic-bot 的消息出口",
|
|
@@ -29,5 +41,11 @@
|
|
|
29
41
|
"http"
|
|
30
42
|
]
|
|
31
43
|
}
|
|
32
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "pnpm build:js && pnpm build:dts",
|
|
47
|
+
"build:js": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=lib/index.js --packages=external",
|
|
48
|
+
"build:dts": "tsc -p tsconfig.json"
|
|
49
|
+
},
|
|
50
|
+
"typings": "lib/index.d.ts"
|
|
33
51
|
}
|
package/src/dbk/version.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const FALLBACK = "0.0.0-dev";
|
|
7
|
+
const PACKAGE_NAME = "koishi-plugin-dynamic-bot";
|
|
7
8
|
|
|
8
9
|
function hereDir(): string {
|
|
9
10
|
try {
|
|
@@ -13,9 +14,33 @@ function hereDir(): string {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
function readName(dir: string): string | undefined {
|
|
18
|
+
try {
|
|
19
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8")) as {
|
|
20
|
+
name?: string;
|
|
21
|
+
};
|
|
22
|
+
return pkg.name;
|
|
23
|
+
} catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function findPackageDir(start: string): string | undefined {
|
|
29
|
+
let dir = start;
|
|
30
|
+
for (let i = 0; i < 8; i++) {
|
|
31
|
+
if (existsSync(join(dir, "package.json")) && readName(dir) === PACKAGE_NAME) {
|
|
32
|
+
return dir;
|
|
33
|
+
}
|
|
34
|
+
const parent = join(dir, "..");
|
|
35
|
+
if (parent === dir) break;
|
|
36
|
+
dir = parent;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
16
41
|
function packageDir(): string {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
42
|
+
const found = findPackageDir(hereDir());
|
|
43
|
+
if (found) return found;
|
|
19
44
|
const fromCwd = join(process.cwd(), "koishi");
|
|
20
45
|
if (existsSync(join(fromCwd, "package.json"))) return fromCwd;
|
|
21
46
|
return process.cwd();
|
package/AGENTS.md
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# koishi/
|
|
2
|
-
|
|
3
|
-
Koishi **Plugin**:执行 DBK,调用已有 `ctx.bots`。不要实现 `Adapter` / `Bot` 去反向连接 dynamic-bot。
|
|
4
|
-
只做生成类型 ↔ `h()` / `session`。不要解析命令、不要 `session.send` 业务回复、不要在这里保存平台 Token 或 OneBot 连接(仍归 Koishi Adapter 配置,含 `adapter-onebot`)。
|
|
5
|
-
`bot.status`:`ONLINE` → `READY`,`CONNECT`/`RECONNECT` → `CONNECTING`,其余 → `UNAVAILABLE`。不要用 `isActive`。
|
|
6
|
-
`targets.list` 在无嵌套 `channel.list` 的 bot 上可以不完整(典型 Telegram),必须设置 incomplete。
|