onebots 0.4.67 → 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
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
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { V11 } from "../../../service/V11";
|
|
2
|
-
import { Message } from "@icqqjs/icqq";
|
|
3
2
|
export declare class CommonAction {
|
|
4
3
|
/**
|
|
5
4
|
* 获取登录信息
|
|
@@ -18,7 +17,7 @@ export declare class CommonAction {
|
|
|
18
17
|
* @param message_id {string} 消息id
|
|
19
18
|
* @param onebot_id {number}
|
|
20
19
|
*/
|
|
21
|
-
getMsg(this: V11, message_id: number): Promise<
|
|
20
|
+
getMsg(this: V11, message_id: number): Promise<V11.MessageRet>;
|
|
22
21
|
/**
|
|
23
22
|
* 获取合并消息
|
|
24
23
|
* @param id {string} 合并id
|
|
@@ -32,7 +32,9 @@ class CommonAction {
|
|
|
32
32
|
*/
|
|
33
33
|
async getMsg(message_id) {
|
|
34
34
|
const msg_id = this.getStrByInt("message_id", message_id);
|
|
35
|
-
let msg = await this.adapter.call(this.oneBot.uin, "V11", "getMessage", [
|
|
35
|
+
let msg = await this.adapter.call(this.oneBot.uin, "V11", "getMessage", [
|
|
36
|
+
msg_id,
|
|
37
|
+
]);
|
|
36
38
|
msg.message_id = message_id; // nonebot v11 要求 message_id 是 number 类型
|
|
37
39
|
msg["real_id"] = msg.message_id; // nonebot 的reply类型会检测real_id是否存在,虽然它从未使用
|
|
38
40
|
return msg;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventMap } from "@icqqjs/icqq";
|
|
3
2
|
import { Config } from "./config";
|
|
4
3
|
import { OneBot } from "../../onebot";
|
|
5
4
|
import { Action } from "./action";
|
|
@@ -141,16 +140,6 @@ export declare namespace V12 {
|
|
|
141
140
|
detail_type: "status_update";
|
|
142
141
|
status: ReturnType<Action["getStatus"]>;
|
|
143
142
|
};
|
|
144
|
-
} & TransformEventMap;
|
|
145
|
-
type TransformEventMap = {
|
|
146
|
-
[P in keyof EventMap]: TransformEventParams<Parameters<EventMap[P]>>;
|
|
147
|
-
};
|
|
148
|
-
type TransformEventParams<T extends any[]> = T extends [infer L, ...infer R] ? L extends object ? L & {
|
|
149
|
-
args: R;
|
|
150
|
-
} : {
|
|
151
|
-
args: [L, ...R];
|
|
152
|
-
} : {
|
|
153
|
-
args: T;
|
|
154
143
|
};
|
|
155
144
|
function success<T extends any>(data: T, retcode?: Result<T>["retcode"], echo?: string): Result<T>;
|
|
156
145
|
function error(message: string, retcode?: Result<null>["retcode"], echo?: string): Result<null>;
|
package/lib/service/V12/index.js
CHANGED
|
@@ -14,7 +14,6 @@ const https_1 = __importDefault(require("https"));
|
|
|
14
14
|
const ws_1 = require("ws");
|
|
15
15
|
const utils_2 = require("../../utils");
|
|
16
16
|
const db_1 = require("../../db");
|
|
17
|
-
const message_1 = require("@icqqjs/icqq/lib/message");
|
|
18
17
|
const service_1 = require("../../service");
|
|
19
18
|
const app_1 = require("../../server/app");
|
|
20
19
|
class V12 extends service_1.Service {
|
|
@@ -353,15 +352,6 @@ class V12 extends service_1.Service {
|
|
|
353
352
|
data.message_type || data.notice_type || data.request_type || data.system_type;
|
|
354
353
|
data.message =
|
|
355
354
|
data.type === "message" ? this.adapter.toSegment("V12", data.message) : data.message;
|
|
356
|
-
if (data.source)
|
|
357
|
-
data.source = {
|
|
358
|
-
...data.source,
|
|
359
|
-
message_id: data.detail_type === "private"
|
|
360
|
-
? (0, message_1.genDmMessageId)(data.source.user_id, data.source.seq, data.source.rand, data.source.time)
|
|
361
|
-
: (0, message_1.genGroupMessageId)(data.group_id, data.source.user_id, data.source.seq, data.source.rand, data.source.time),
|
|
362
|
-
user_id: data.source.user_id,
|
|
363
|
-
message: data.source.message,
|
|
364
|
-
};
|
|
365
355
|
return V12.formatPayload(this.oneBot.uin, event, data);
|
|
366
356
|
}
|
|
367
357
|
system_online(data) { }
|
|
@@ -403,7 +393,7 @@ class V12 extends service_1.Service {
|
|
|
403
393
|
}
|
|
404
394
|
transformMedia(segment) {
|
|
405
395
|
const file = this.getFile(segment.data.file_id);
|
|
406
|
-
if (file)
|
|
396
|
+
if (file && file.data)
|
|
407
397
|
return {
|
|
408
398
|
type: segment.type,
|
|
409
399
|
data: {
|