onebots 0.4.66 → 0.4.68
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
CHANGED
|
@@ -23,6 +23,15 @@ class Adapter extends events_1.EventEmitter {
|
|
|
23
23
|
this.config = config;
|
|
24
24
|
this.oneBots = new Map();
|
|
25
25
|
_Adapter_logger.set(this, void 0);
|
|
26
|
+
this.on("message.receive", (uin, ...args) => {
|
|
27
|
+
this.oneBots.get(uin)?.emit("message.receive", ...args);
|
|
28
|
+
});
|
|
29
|
+
this.on("notice.receive", (uin, ...args) => {
|
|
30
|
+
this.oneBots.get(uin)?.emit("notice.receive", ...args);
|
|
31
|
+
});
|
|
32
|
+
this.on("request.receive", (uin, ...args) => {
|
|
33
|
+
this.oneBots.get(uin)?.emit("request.receive", ...args);
|
|
34
|
+
});
|
|
26
35
|
}
|
|
27
36
|
materialize(content) {
|
|
28
37
|
return content
|
|
@@ -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;
|
package/lib/service/V11/index.js
CHANGED
|
@@ -141,16 +141,16 @@ class V11 extends service_1.Service {
|
|
|
141
141
|
});
|
|
142
142
|
}, this.config.heartbeat * 1000);
|
|
143
143
|
}
|
|
144
|
-
this.
|
|
145
|
-
const payload = this.adapter.formatEventPayload(uin, "V11", "message", event);
|
|
144
|
+
this.oneBot.on("message.receive", event => {
|
|
145
|
+
const payload = this.adapter.formatEventPayload(this.oneBot.uin, "V11", "message", event);
|
|
146
146
|
this.dispatch(payload);
|
|
147
147
|
});
|
|
148
|
-
this.
|
|
149
|
-
const payload = this.adapter.formatEventPayload(uin, "V11", "notice", event);
|
|
148
|
+
this.oneBot.on("notice.receive", event => {
|
|
149
|
+
const payload = this.adapter.formatEventPayload(this.oneBot.uin, "V11", "notice", event);
|
|
150
150
|
this.dispatch(payload);
|
|
151
151
|
});
|
|
152
|
-
this.
|
|
153
|
-
const payload = this.adapter.formatEventPayload(uin, "V11", "request", event);
|
|
152
|
+
this.oneBot.on("request.receive", event => {
|
|
153
|
+
const payload = this.adapter.formatEventPayload(this.oneBot.uin, "V11", "request", event);
|
|
154
154
|
this.dispatch(payload);
|
|
155
155
|
});
|
|
156
156
|
}
|
|
@@ -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 {
|
|
@@ -136,16 +135,16 @@ class V12 extends service_1.Service {
|
|
|
136
135
|
}));
|
|
137
136
|
}, this.config.heartbeat * 1000);
|
|
138
137
|
}
|
|
139
|
-
this.
|
|
140
|
-
const payload = this.adapter.formatEventPayload(uin, "V12", "message", event);
|
|
138
|
+
this.oneBot.on("message.receive", event => {
|
|
139
|
+
const payload = this.adapter.formatEventPayload(this.oneBot.uin, "V12", "message", event);
|
|
141
140
|
this.dispatch(payload);
|
|
142
141
|
});
|
|
143
|
-
this.
|
|
144
|
-
const payload = this.adapter.formatEventPayload(uin, "V12", "notice", event);
|
|
142
|
+
this.oneBot.on("notice.receive", event => {
|
|
143
|
+
const payload = this.adapter.formatEventPayload(this.oneBot.uin, "V12", "notice", event);
|
|
145
144
|
this.dispatch(payload);
|
|
146
145
|
});
|
|
147
|
-
this.
|
|
148
|
-
const payload = this.adapter.formatEventPayload(uin, "V12", "request", event);
|
|
146
|
+
this.oneBot.on("request.receive", event => {
|
|
147
|
+
const payload = this.adapter.formatEventPayload(this.oneBot.uin, "V12", "request", event);
|
|
149
148
|
this.dispatch(payload);
|
|
150
149
|
});
|
|
151
150
|
}
|
|
@@ -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: {
|