onebots 0.4.2 → 0.4.4
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.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import 'icqq-cq-enable';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { App } from "./server/app";
|
|
5
|
-
import { Client } from "icqq";
|
|
5
|
+
import { Client, Platform } from "icqq";
|
|
6
6
|
import { V11 } from "./service/V11";
|
|
7
7
|
import { V12 } from "./service/V12";
|
|
8
8
|
import { MayBeArray } from "./types";
|
|
@@ -32,6 +32,7 @@ export declare namespace OneBot {
|
|
|
32
32
|
type Version = 'V11' | 'V12';
|
|
33
33
|
type Config<V extends Version = 'V11'> = ({
|
|
34
34
|
version?: V;
|
|
35
|
+
platform?: Platform;
|
|
35
36
|
password?: string;
|
|
36
37
|
} & (V extends 'V11' ? V11.Config : V12.Config));
|
|
37
38
|
interface Base {
|
package/lib/onebot.js
CHANGED
|
@@ -47,7 +47,10 @@ class OneBot extends events_1.EventEmitter {
|
|
|
47
47
|
this.app = app;
|
|
48
48
|
this.uin = uin;
|
|
49
49
|
config = [].concat(config);
|
|
50
|
+
let platform = this.app.config.platform;
|
|
50
51
|
this.config = config.map(c => {
|
|
52
|
+
if (c.platform)
|
|
53
|
+
platform = c.platform;
|
|
51
54
|
if (c.password)
|
|
52
55
|
this.password = c.password;
|
|
53
56
|
if (!c.version)
|
|
@@ -61,7 +64,7 @@ class OneBot extends events_1.EventEmitter {
|
|
|
61
64
|
throw new Error('不支持的oneBot版本:' + c.version);
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
|
-
this.client = new icqq_1.Client({ platform
|
|
67
|
+
this.client = new icqq_1.Client({ platform, data_dir: (0, path_1.join)(app_1.App.configDir, 'data') });
|
|
65
68
|
this.instances = this.config.map(c => {
|
|
66
69
|
switch (c.version) {
|
|
67
70
|
case 'V11':
|
|
@@ -174,13 +177,13 @@ class OneBot extends events_1.EventEmitter {
|
|
|
174
177
|
if (data.source) {
|
|
175
178
|
switch (data.message_type) {
|
|
176
179
|
case 'group':
|
|
177
|
-
data.message.
|
|
180
|
+
data.message.unshift({
|
|
178
181
|
type: 'reply',
|
|
179
182
|
message_id: (0, message_1.genGroupMessageId)(data.group_id, data.source.user_id, data.source.seq, data.source.rand, data.source.time)
|
|
180
183
|
});
|
|
181
184
|
break;
|
|
182
185
|
case 'private':
|
|
183
|
-
data.message.
|
|
186
|
+
data.message.unshift({
|
|
184
187
|
type: 'reply',
|
|
185
188
|
message_id: (0, message_1.genDmMessageId)(data.source.user_id, data.source.seq, data.source.rand, data.source.time)
|
|
186
189
|
});
|
|
@@ -7,6 +7,68 @@ export declare class CommonAction {
|
|
|
7
7
|
* @param message_id {string} 消息id
|
|
8
8
|
*/
|
|
9
9
|
deleteMsg(this: V12, message_id: string): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* 获取消息详情
|
|
12
|
+
*/ F: any;
|
|
13
|
+
getMsg(this: V12, message_id: string): Promise<{
|
|
14
|
+
message: V12.SegmentElem<keyof V12.SegmentMap>[];
|
|
15
|
+
message_type: "group";
|
|
16
|
+
sub_type: "normal" | "anonymous";
|
|
17
|
+
group_id: number;
|
|
18
|
+
group_name: string;
|
|
19
|
+
anonymous: import("icqq").Anonymous;
|
|
20
|
+
block: boolean;
|
|
21
|
+
atme: boolean;
|
|
22
|
+
atall: boolean;
|
|
23
|
+
sender: {
|
|
24
|
+
user_id: number;
|
|
25
|
+
nickname: string;
|
|
26
|
+
card: string;
|
|
27
|
+
sex: import("icqq").Gender;
|
|
28
|
+
age: number;
|
|
29
|
+
area: string;
|
|
30
|
+
level: number;
|
|
31
|
+
role: import("icqq").GroupRole;
|
|
32
|
+
title: string;
|
|
33
|
+
};
|
|
34
|
+
user_id: number;
|
|
35
|
+
post_type: "message";
|
|
36
|
+
time: number;
|
|
37
|
+
raw_message: string;
|
|
38
|
+
font: string;
|
|
39
|
+
message_id: string;
|
|
40
|
+
seq: number;
|
|
41
|
+
rand: number;
|
|
42
|
+
source?: import("icqq").Quotable;
|
|
43
|
+
pktnum: number;
|
|
44
|
+
index: number;
|
|
45
|
+
div: number;
|
|
46
|
+
} | {
|
|
47
|
+
message: V12.SegmentElem<keyof V12.SegmentMap>[];
|
|
48
|
+
message_type: "private";
|
|
49
|
+
sub_type: "self" | "other" | "group" | "friend";
|
|
50
|
+
from_id: number;
|
|
51
|
+
to_id: number;
|
|
52
|
+
auto_reply: boolean;
|
|
53
|
+
sender: {
|
|
54
|
+
user_id: number;
|
|
55
|
+
nickname: string;
|
|
56
|
+
group_id: number;
|
|
57
|
+
discuss_id: number;
|
|
58
|
+
};
|
|
59
|
+
user_id: number;
|
|
60
|
+
post_type: "message";
|
|
61
|
+
time: number;
|
|
62
|
+
raw_message: string;
|
|
63
|
+
font: string;
|
|
64
|
+
message_id: string;
|
|
65
|
+
seq: number;
|
|
66
|
+
rand: number;
|
|
67
|
+
source?: import("icqq").Quotable;
|
|
68
|
+
pktnum: number;
|
|
69
|
+
index: number;
|
|
70
|
+
div: number;
|
|
71
|
+
}>;
|
|
10
72
|
getSelfInfo(this: V12): {
|
|
11
73
|
user_id: string;
|
|
12
74
|
platform: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonAction = void 0;
|
|
4
|
+
const V12_1 = require("../../../service/V12");
|
|
4
5
|
const icqq_1 = require("icqq");
|
|
5
6
|
const utils_1 = require("../../../utils");
|
|
6
7
|
const onebot_1 = require("../../../onebot");
|
|
@@ -16,6 +17,15 @@ class CommonAction {
|
|
|
16
17
|
deleteMsg(message_id) {
|
|
17
18
|
return this.client.deleteMsg(message_id);
|
|
18
19
|
}
|
|
20
|
+
async getMsg(message_id) {
|
|
21
|
+
const message = await this.client.getMsg(message_id);
|
|
22
|
+
if (!message)
|
|
23
|
+
throw new Error('消息不存在');
|
|
24
|
+
return {
|
|
25
|
+
...message,
|
|
26
|
+
message: V12_1.V12.toSegment(message.message)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
19
29
|
getSelfInfo() {
|
|
20
30
|
return {
|
|
21
31
|
user_id: this.oneBot.uin + '',
|
|
@@ -42,7 +42,11 @@ export declare class V12 extends EventEmitter implements OneBot.Base {
|
|
|
42
42
|
detail_type: E;
|
|
43
43
|
type: string;
|
|
44
44
|
sub_type: string;
|
|
45
|
-
} & Omit<V12.BotEventMap[E], E
|
|
45
|
+
} & Omit<V12.BotEventMap[E], E> & {
|
|
46
|
+
group: any;
|
|
47
|
+
frind: any;
|
|
48
|
+
member: any;
|
|
49
|
+
};
|
|
46
50
|
dispatch(data: Record<string, any>): void;
|
|
47
51
|
apply(req: V12.RequestAction): Promise<string>;
|
|
48
52
|
private _httpRequestHandler;
|
|
@@ -221,7 +225,11 @@ export declare namespace V12 {
|
|
|
221
225
|
detail_type: K;
|
|
222
226
|
type: string;
|
|
223
227
|
sub_type: string;
|
|
224
|
-
} & Omit<BotEventMap[K], K
|
|
228
|
+
} & Omit<BotEventMap[K], K> & {
|
|
229
|
+
group: any;
|
|
230
|
+
frind: any;
|
|
231
|
+
member: any;
|
|
232
|
+
};
|
|
225
233
|
type RequestAction = {
|
|
226
234
|
action: string;
|
|
227
235
|
params: Record<string, any>;
|
package/lib/service/V12/index.js
CHANGED
|
@@ -577,7 +577,7 @@ class V12 extends events_1.EventEmitter {
|
|
|
577
577
|
else {
|
|
578
578
|
code = 10003;
|
|
579
579
|
this.logger.debug(e);
|
|
580
|
-
message = "请求格式错误";
|
|
580
|
+
message = e?.message || "请求格式错误";
|
|
581
581
|
}
|
|
582
582
|
ws.send(JSON.stringify({
|
|
583
583
|
retcode: code,
|
|
@@ -689,7 +689,10 @@ exports.V12 = V12;
|
|
|
689
689
|
detail_type: type,
|
|
690
690
|
type: 'meta',
|
|
691
691
|
sub_type: '',
|
|
692
|
-
...data
|
|
692
|
+
...data,
|
|
693
|
+
group: data['group']?.info,
|
|
694
|
+
frind: data['friend']?.info,
|
|
695
|
+
member: data['member']?.info,
|
|
693
696
|
};
|
|
694
697
|
}
|
|
695
698
|
V12.formatPayload = formatPayload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onebots",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "基于icqq的多例oneBot实现",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@koa/router": "^10.1.1",
|
|
57
57
|
"@zhinjs/shared": "^0.0.9",
|
|
58
|
-
"icqq": "^0.3.
|
|
58
|
+
"icqq": "^0.3.15",
|
|
59
59
|
"icqq-cq-enable": "^1.0.0",
|
|
60
60
|
"js-yaml": "^4.1.0",
|
|
61
61
|
"koa": "^2.13.4",
|