onebots 0.4.17 → 0.4.18
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/onebot.js +1 -1
- package/lib/server/app.js +6 -6
- package/lib/server/router.d.ts +1 -1
- package/lib/service/V11/index.js +4 -3
- package/lib/service/V12/index.js +1 -1
- package/package.json +2 -1
package/lib/onebot.js
CHANGED
|
@@ -202,5 +202,5 @@ var OneBotStatus;
|
|
|
202
202
|
(function (OneBotStatus) {
|
|
203
203
|
OneBotStatus[OneBotStatus["Good"] = 0] = "Good";
|
|
204
204
|
OneBotStatus[OneBotStatus["Bad"] = 1] = "Bad";
|
|
205
|
-
})(OneBotStatus
|
|
205
|
+
})(OneBotStatus || (exports.OneBotStatus = OneBotStatus = {}));
|
|
206
206
|
exports.BOOLS = ["no_cache", "auto_escape", "as_long", "enable", "reject_add_request", "is_dismiss", "approve", "block"];
|
package/lib/server/app.js
CHANGED
|
@@ -47,7 +47,7 @@ class App extends koa_1.default {
|
|
|
47
47
|
constructor(config = {}) {
|
|
48
48
|
super(config);
|
|
49
49
|
this.oneBots = [];
|
|
50
|
-
this.config = (0, utils_1.deepMerge)((0, utils_1.deepClone)(
|
|
50
|
+
this.config = (0, utils_1.deepMerge)((0, utils_1.deepClone)(_a.defaultConfig), config);
|
|
51
51
|
this.logger = (0, log4js_1.getLogger)('[icqq-OneBot]');
|
|
52
52
|
this.logger.level = this.config.log_level;
|
|
53
53
|
this.router = new router_1.Router({ prefix: config.path });
|
|
@@ -86,7 +86,7 @@ class App extends koa_1.default {
|
|
|
86
86
|
this.config[uin] = config;
|
|
87
87
|
const oneBot = this.createOneBot(uin, config);
|
|
88
88
|
oneBot.startListen();
|
|
89
|
-
(0, fs_1.writeFileSync)(
|
|
89
|
+
(0, fs_1.writeFileSync)(_a.configPath, js_yaml_1.default.dump((0, utils_1.deepClone)(this.config)));
|
|
90
90
|
}
|
|
91
91
|
updateAccount(uin, config) {
|
|
92
92
|
if (typeof uin !== "number")
|
|
@@ -112,7 +112,7 @@ class App extends koa_1.default {
|
|
|
112
112
|
oneBot.stop(force);
|
|
113
113
|
delete this.config[uin];
|
|
114
114
|
this.oneBots.splice(currentIdx, 1);
|
|
115
|
-
(0, fs_1.writeFileSync)(
|
|
115
|
+
(0, fs_1.writeFileSync)(_a.configPath, js_yaml_1.default.dump(this.config));
|
|
116
116
|
}
|
|
117
117
|
createOneBot(uin, config) {
|
|
118
118
|
const oneBot = new onebot_1.OneBot(this, uin, config);
|
|
@@ -132,11 +132,11 @@ class App extends koa_1.default {
|
|
|
132
132
|
});
|
|
133
133
|
this.router.get('/qrcode', (ctx) => {
|
|
134
134
|
const { uin } = ctx.query;
|
|
135
|
-
const uinUrl = path.join(
|
|
135
|
+
const uinUrl = path.join(_a.configDir, 'data', uin);
|
|
136
136
|
if (!(0, fs_1.existsSync)(uinUrl)) {
|
|
137
137
|
return ctx.res.writeHead(400).end('未登录');
|
|
138
138
|
}
|
|
139
|
-
const qrcodePath = path.join(
|
|
139
|
+
const qrcodePath = path.join(_a.configDir, 'data', uin, 'qrcode.png');
|
|
140
140
|
let file = null;
|
|
141
141
|
try {
|
|
142
142
|
file = (0, fs_2.readFileSync)(qrcodePath); //读取文件
|
|
@@ -243,4 +243,4 @@ exports.defineConfig = defineConfig;
|
|
|
243
243
|
},
|
|
244
244
|
log_level: 'info',
|
|
245
245
|
};
|
|
246
|
-
})(App
|
|
246
|
+
})(App || (exports.App = App = {}));
|
package/lib/server/router.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import { WebSocketServer } from "ws";
|
|
|
5
5
|
import http from "http";
|
|
6
6
|
export declare class Router extends KoaRouter {
|
|
7
7
|
wsStack: WebSocketServer[];
|
|
8
|
-
ws(path: string, server: http.Server): import("ws").Server<import("ws").
|
|
8
|
+
ws(path: string, server: http.Server): import("ws").Server<typeof import("ws"), typeof http.IncomingMessage>;
|
|
9
9
|
}
|
package/lib/service/V11/index.js
CHANGED
|
@@ -336,10 +336,11 @@ class V11 extends events_1.EventEmitter {
|
|
|
336
336
|
*/
|
|
337
337
|
_webSocketHandler(ws) {
|
|
338
338
|
ws.on("message", async (msg) => {
|
|
339
|
-
|
|
339
|
+
const msgStr = msg.toString();
|
|
340
|
+
this.logger.info(" 收到ws消息:", msgStr.length > 2e3 ? msgStr.slice(0, 2e3) + ` ... ${msgStr.length - 2e3} more chars` : msgStr);
|
|
340
341
|
var data;
|
|
341
342
|
try {
|
|
342
|
-
data = JSON.parse(
|
|
343
|
+
data = JSON.parse(msgStr);
|
|
343
344
|
let ret;
|
|
344
345
|
if (data.action.startsWith(".handle_quick_operation")) {
|
|
345
346
|
const event = data.params.context, res = data.params.operation;
|
|
@@ -605,4 +606,4 @@ exports.V11 = V11;
|
|
|
605
606
|
};
|
|
606
607
|
}
|
|
607
608
|
V11.genMetaEvent = genMetaEvent;
|
|
608
|
-
})(V11
|
|
609
|
+
})(V11 || (exports.V11 = V11 = {}));
|
package/lib/service/V12/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onebots",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.18",
|
|
4
4
|
"description": "基于icqq的多例oneBot实现",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"koa": "^2.13.4",
|
|
64
64
|
"koa-bodyparser": "^4.3.0",
|
|
65
65
|
"log4js": "^6.5.2",
|
|
66
|
+
"mime-types": "^2.1.35",
|
|
66
67
|
"ws": "^8.8.0"
|
|
67
68
|
}
|
|
68
69
|
}
|