onebots 0.4.68 → 0.4.70
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 +17 -9
- 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,31 @@ 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) {
|
|
311
|
-
|
|
310
|
+
function createOnebots(config = "config.yaml", cp = null) {
|
|
311
|
+
const isStartWithConfigFile = typeof config === "string";
|
|
312
|
+
if (isStartWithConfigFile) {
|
|
312
313
|
config = path.resolve(process_1.default.cwd(), config);
|
|
313
314
|
App.configDir = path.dirname(config);
|
|
314
315
|
if (!(0, fs_1.existsSync)(App.configDir)) {
|
|
315
316
|
(0, fs_1.mkdirSync)(App.configDir);
|
|
316
317
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
(0, fs_1.copyFileSync)(path.resolve(__dirname, "../config.sample.yaml"), App.configPath);
|
|
318
|
+
config = js_yaml_1.default.load((0, fs_2.readFileSync)(App.configPath, "utf8"));
|
|
319
|
+
}
|
|
320
|
+
if (!(0, fs_1.existsSync)(App.configPath)) {
|
|
321
|
+
(0, fs_1.copyFileSync)(path.resolve(__dirname, "../config.sample.yaml"), App.configPath);
|
|
322
|
+
if (isStartWithConfigFile) {
|
|
323
323
|
console.log("未找到对应配置文件,已自动生成默认配置文件,请修改配置文件后重新启动");
|
|
324
324
|
console.log(`配置文件在: ${App.configPath}`);
|
|
325
325
|
process_1.default.exit();
|
|
326
326
|
}
|
|
327
|
-
|
|
327
|
+
else {
|
|
328
|
+
console.log("未找到对应配置文件,已自动生成默认配置文件");
|
|
329
|
+
console.log(`配置文件在: ${App.configPath}`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (!(0, fs_1.existsSync)(App.dataDir)) {
|
|
333
|
+
(0, fs_1.mkdirSync)(App.dataDir);
|
|
334
|
+
console.log("已为你创建数据存储目录", App.dataDir);
|
|
328
335
|
}
|
|
329
336
|
(0, log4js_1.configure)({
|
|
330
337
|
appenders: {
|
|
@@ -334,6 +341,7 @@ function createOnebots(config = "config.yaml", cp) {
|
|
|
334
341
|
},
|
|
335
342
|
files: {
|
|
336
343
|
type: "file",
|
|
344
|
+
maxLogSize: 1024 * 1024 * 50,
|
|
337
345
|
filename: path.join(process_1.default.cwd(), "onebots.log"),
|
|
338
346
|
},
|
|
339
347
|
},
|