onebots 0.4.68 → 0.4.69
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/server/app.d.ts +1 -1
- package/lib/server/app.js +15 -8
- package/package.json +1 -1
package/lib/server/app.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare class App extends Koa {
|
|
|
67
67
|
reload(config: App.Config): Promise<void>;
|
|
68
68
|
stop(): Promise<void>;
|
|
69
69
|
}
|
|
70
|
-
export declare function createOnebots(config
|
|
70
|
+
export declare function createOnebots(config?: App.Config | string, cp?: ChildProcess | null): App;
|
|
71
71
|
export declare function defineConfig(config: App.Config): App.Config;
|
|
72
72
|
export declare namespace App {
|
|
73
73
|
const ADAPTERS: Map<string, AdapterClass>;
|
package/lib/server/app.js
CHANGED
|
@@ -307,24 +307,30 @@ class App extends koa_1.default {
|
|
|
307
307
|
}
|
|
308
308
|
exports.App = App;
|
|
309
309
|
App.configDir = path.join(os.homedir(), ".onebots");
|
|
310
|
-
function createOnebots(config = "config.yaml", cp) {
|
|
310
|
+
function createOnebots(config = "config.yaml", cp = null) {
|
|
311
311
|
if (typeof config === "string") {
|
|
312
312
|
config = path.resolve(process_1.default.cwd(), config);
|
|
313
313
|
App.configDir = path.dirname(config);
|
|
314
314
|
if (!(0, fs_1.existsSync)(App.configDir)) {
|
|
315
315
|
(0, fs_1.mkdirSync)(App.configDir);
|
|
316
316
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
(0, fs_1.copyFileSync)(path.resolve(__dirname, "../config.sample.yaml"), App.configPath);
|
|
317
|
+
config = js_yaml_1.default.load((0, fs_2.readFileSync)(App.configPath, "utf8"));
|
|
318
|
+
}
|
|
319
|
+
if (!(0, fs_1.existsSync)(App.configPath)) {
|
|
320
|
+
(0, fs_1.copyFileSync)(path.resolve(__dirname, "../config.sample.yaml"), App.configPath);
|
|
321
|
+
if (typeof config === "string") {
|
|
323
322
|
console.log("未找到对应配置文件,已自动生成默认配置文件,请修改配置文件后重新启动");
|
|
324
323
|
console.log(`配置文件在: ${App.configPath}`);
|
|
325
324
|
process_1.default.exit();
|
|
326
325
|
}
|
|
327
|
-
|
|
326
|
+
else {
|
|
327
|
+
console.log("未找到对应配置文件,已自动生成默认配置文件");
|
|
328
|
+
console.log(`配置文件在: ${App.configPath}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (!(0, fs_1.existsSync)(App.dataDir)) {
|
|
332
|
+
(0, fs_1.mkdirSync)(App.dataDir);
|
|
333
|
+
console.log("已为你创建数据存储目录", App.dataDir);
|
|
328
334
|
}
|
|
329
335
|
(0, log4js_1.configure)({
|
|
330
336
|
appenders: {
|
|
@@ -334,6 +340,7 @@ function createOnebots(config = "config.yaml", cp) {
|
|
|
334
340
|
},
|
|
335
341
|
files: {
|
|
336
342
|
type: "file",
|
|
343
|
+
maxLogSize: 1024 * 1024 * 50,
|
|
337
344
|
filename: path.join(process_1.default.cwd(), "onebots.log"),
|
|
338
345
|
},
|
|
339
346
|
},
|