onebots 0.4.64 → 0.4.65
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.js +6 -5
- package/lib/db.js +1 -1
- package/lib/server/app.js +9 -4
- package/package.json +9 -5
package/lib/adapter.js
CHANGED
|
@@ -63,7 +63,7 @@ class Adapter extends events_1.EventEmitter {
|
|
|
63
63
|
.join("");
|
|
64
64
|
}
|
|
65
65
|
fromCqcode(version, message) {
|
|
66
|
-
const regExpMatchArray = message.match(/\[CQ:([a-z]+),([
|
|
66
|
+
const regExpMatchArray = message.match(/\[CQ:([a-z]+),([^\]]+)]/);
|
|
67
67
|
if (!regExpMatchArray)
|
|
68
68
|
return [
|
|
69
69
|
{
|
|
@@ -75,10 +75,10 @@ class Adapter extends events_1.EventEmitter {
|
|
|
75
75
|
];
|
|
76
76
|
const result = [];
|
|
77
77
|
while (message.length) {
|
|
78
|
-
const [match] = message.match(/\[CQ:([a-z]+),([
|
|
78
|
+
const [match] = message.match(/\[CQ:([a-z]+),([^\]]+)]/) || [];
|
|
79
79
|
if (!match)
|
|
80
80
|
break;
|
|
81
|
-
const prevText = message.substring(0, match
|
|
81
|
+
const prevText = message.substring(0, message.indexOf(match));
|
|
82
82
|
if (prevText) {
|
|
83
83
|
result.push({
|
|
84
84
|
type: "text",
|
|
@@ -89,9 +89,10 @@ class Adapter extends events_1.EventEmitter {
|
|
|
89
89
|
}
|
|
90
90
|
const [type, ...valueArr] = match.substring(1, match.length - 1).split(",");
|
|
91
91
|
result.push({
|
|
92
|
-
type: type,
|
|
92
|
+
type: type.split(":").at(-1),
|
|
93
93
|
data: Object.fromEntries(valueArr.map(item => {
|
|
94
|
-
const [key,
|
|
94
|
+
const [key, ...values] = item.split("=");
|
|
95
|
+
const value = values.join("=");
|
|
95
96
|
return [key, type === "reply" && key === "id" ? +value : value];
|
|
96
97
|
})),
|
|
97
98
|
});
|
package/lib/db.js
CHANGED
|
@@ -66,7 +66,7 @@ class JsonDB {
|
|
|
66
66
|
while (parentPath.length) {
|
|
67
67
|
const currentKey = parentPath.shift();
|
|
68
68
|
if (!Reflect.has(temp, currentKey))
|
|
69
|
-
Reflect.set(temp,
|
|
69
|
+
Reflect.set(temp, currentKey, {});
|
|
70
70
|
temp = Reflect.get(temp, currentKey);
|
|
71
71
|
}
|
|
72
72
|
if (temp[key] !== undefined)
|
package/lib/server/app.js
CHANGED
|
@@ -90,10 +90,15 @@ class App extends koa_1.default {
|
|
|
90
90
|
this.use((0, koa_bodyparser_1.default)())
|
|
91
91
|
.use(this.router.routes())
|
|
92
92
|
.use(this.router.allowedMethods())
|
|
93
|
-
.use((
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
.use(async (ctx, next) => {
|
|
94
|
+
const adapter = ctx.path?.slice(1)?.split("/")[0];
|
|
95
|
+
if (this.adapters.has(adapter))
|
|
96
|
+
return next();
|
|
97
|
+
return (0, koa_basic_auth_1.default)({
|
|
98
|
+
name: this.config.username,
|
|
99
|
+
pass: this.config.password,
|
|
100
|
+
})(ctx, next);
|
|
101
|
+
})
|
|
97
102
|
.use((0, koa_static_1.default)(path.resolve(__dirname, "../../dist")));
|
|
98
103
|
this.httpServer = (0, http_1.createServer)(this.callback());
|
|
99
104
|
this.ws = this.router.ws("/", this.httpServer);
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onebots",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.65",
|
|
4
4
|
"description": "基于icqq的多例oneBot实现",
|
|
5
|
-
"engines": {
|
|
6
|
-
"node": ">=16"
|
|
7
|
-
},
|
|
8
5
|
"main": "lib/index.js",
|
|
9
6
|
"bin": {
|
|
10
7
|
"onebots": "./lib/bin.js"
|
|
@@ -21,6 +18,13 @@
|
|
|
21
18
|
"docs:build": "vitepress build docs",
|
|
22
19
|
"docs:preview": "vitepress preview docs"
|
|
23
20
|
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=16"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org"
|
|
27
|
+
},
|
|
24
28
|
"repository": {
|
|
25
29
|
"type": "git",
|
|
26
30
|
"url": "git+https://github.com/liucl-cn/onebots.git"
|
|
@@ -89,4 +93,4 @@
|
|
|
89
93
|
"reflect-metadata": "^0.1.13",
|
|
90
94
|
"ws": "^8.16.0"
|
|
91
95
|
}
|
|
92
|
-
}
|
|
96
|
+
}
|