onebots 0.4.83 → 0.4.86
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/dist/assets/index-DjTPnoDa.js +19 -0
- package/dist/index.html +1 -1
- package/lib/adapter.d.ts +1 -2
- package/lib/adapters/dingtalk/utils.js +4 -5
- package/lib/adapters/icqq/index.d.ts +2 -0
- package/lib/adapters/icqq/index.js +30 -0
- package/lib/adapters/icqq/shareMusicCustom.js +2 -3
- package/lib/adapters/icqq/utils.js +4 -5
- package/lib/adapters/qq/utils.js +4 -5
- package/lib/adapters/wechat/utils.js +4 -5
- package/lib/onebot.d.ts +1 -1
- package/lib/server/app.d.ts +0 -5
- package/lib/server/app.js +3 -3
- package/lib/server/router.d.ts +0 -2
- package/lib/service/V11/action/friend.d.ts +6 -0
- package/lib/service/V11/action/friend.js +12 -0
- package/lib/service/V11/action/group.d.ts +6 -0
- package/lib/service/V11/action/group.js +12 -0
- package/lib/service/V11/index.d.ts +5 -1
- package/lib/service/V12/index.d.ts +5 -1
- package/lib/service.d.ts +0 -1
- package/lib/service.js +1 -1
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +21 -21
- package/package.json +1 -1
- package/dist/assets/index-BI8O0L7d.js +0 -19
package/lib/onebot.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { EventEmitter } from "events";
|
|
3
2
|
import { V11 } from "./service/V11";
|
|
4
3
|
import { V12 } from "./service/V12";
|
|
@@ -69,5 +68,6 @@ export declare namespace OneBot {
|
|
|
69
68
|
dispatch(...args: any[]): any;
|
|
70
69
|
apply(...args: any[]): any;
|
|
71
70
|
}
|
|
71
|
+
type MessageNode<V extends Version> = V extends "V11" ? V11.MessageNode : V12.MessageNode;
|
|
72
72
|
}
|
|
73
73
|
export declare const BOOLS: string[];
|
package/lib/server/app.d.ts
CHANGED
package/lib/server/app.js
CHANGED
|
@@ -26,7 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.App = void 0;
|
|
30
|
+
exports.createOnebots = createOnebots;
|
|
31
|
+
exports.defineConfig = defineConfig;
|
|
30
32
|
const koa_1 = __importDefault(require("koa"));
|
|
31
33
|
const os = __importStar(require("os"));
|
|
32
34
|
require("reflect-metadata");
|
|
@@ -369,11 +371,9 @@ function createOnebots(config = "config.yaml", cp = null) {
|
|
|
369
371
|
process_1.default.on("disconnect", () => cp.kill());
|
|
370
372
|
return new App(config);
|
|
371
373
|
}
|
|
372
|
-
exports.createOnebots = createOnebots;
|
|
373
374
|
function defineConfig(config) {
|
|
374
375
|
return config;
|
|
375
376
|
}
|
|
376
|
-
exports.defineConfig = defineConfig;
|
|
377
377
|
(function (App) {
|
|
378
378
|
App.ADAPTERS = new Map();
|
|
379
379
|
App.defaultConfig = {
|
package/lib/server/router.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ export declare class FriendAction {
|
|
|
7
7
|
* @param message_id {number} 引用的消息ID
|
|
8
8
|
*/
|
|
9
9
|
sendPrivateMsg(this: V11, user_id: number, message: V11.Sendable, message_id?: number): Promise<V11.MessageRet>;
|
|
10
|
+
/**
|
|
11
|
+
* 发送转发消息
|
|
12
|
+
* @param user_id {number} 用户id
|
|
13
|
+
* @param messages {V11.MessageNode[]} 转发节点
|
|
14
|
+
*/
|
|
15
|
+
sendPrivateForwardMsg(this: V11, user_id: number, messages: V11.MessageNode[]): Promise<any>;
|
|
10
16
|
/**
|
|
11
17
|
* 获取好友列表
|
|
12
18
|
*/
|
|
@@ -17,6 +17,18 @@ class FriendAction {
|
|
|
17
17
|
msg_id,
|
|
18
18
|
]);
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* 发送转发消息
|
|
22
|
+
* @param user_id {number} 用户id
|
|
23
|
+
* @param messages {V11.MessageNode[]} 转发节点
|
|
24
|
+
*/
|
|
25
|
+
async sendPrivateForwardMsg(user_id, messages) {
|
|
26
|
+
const uid = this.getStrByInt("user_id", user_id);
|
|
27
|
+
return this.adapter.call(this.oneBot.uin, "V11", "sendPrivateForwardMessage", [
|
|
28
|
+
uid,
|
|
29
|
+
messages,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
20
32
|
/**
|
|
21
33
|
* 获取好友列表
|
|
22
34
|
*/
|
|
@@ -7,6 +7,12 @@ export declare class GroupAction {
|
|
|
7
7
|
* @param message_id {number} 引用的消息ID
|
|
8
8
|
*/
|
|
9
9
|
sendGroupMsg(this: V11, group_id: number, message: V11.Sendable, message_id?: number): Promise<V11.MessageRet>;
|
|
10
|
+
/**
|
|
11
|
+
* 发送群聊转发消息
|
|
12
|
+
* @param group_id {number} 群id
|
|
13
|
+
* @param messages {V11.MessageNode[]} 转发消息内容
|
|
14
|
+
*/
|
|
15
|
+
sendGroupForwardMsg(this: V11, group_id: number, messages: V11.MessageNode[]): Promise<any>;
|
|
10
16
|
/**
|
|
11
17
|
* 群组踢人
|
|
12
18
|
* @param group_id {number} 群id
|
|
@@ -17,6 +17,18 @@ class GroupAction {
|
|
|
17
17
|
msg_id,
|
|
18
18
|
]);
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* 发送群聊转发消息
|
|
22
|
+
* @param group_id {number} 群id
|
|
23
|
+
* @param messages {V11.MessageNode[]} 转发消息内容
|
|
24
|
+
*/
|
|
25
|
+
async sendGroupForwardMsg(group_id, messages) {
|
|
26
|
+
const gid = this.getStrByInt("group_id", group_id);
|
|
27
|
+
return this.adapter.call(this.oneBot.uin, "V11", "sendGroupForwardMessage", [
|
|
28
|
+
gid,
|
|
29
|
+
messages,
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
20
32
|
/**
|
|
21
33
|
* 群组踢人
|
|
22
34
|
* @param group_id {number} 群id
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Config } from "./config";
|
|
3
2
|
import { Action } from "./action";
|
|
4
3
|
import { OneBot, OneBotStatus } from "../../onebot";
|
|
@@ -129,6 +128,11 @@ export declare namespace V11 {
|
|
|
129
128
|
interface Message {
|
|
130
129
|
message: Sendable;
|
|
131
130
|
}
|
|
131
|
+
type MessageNode = {
|
|
132
|
+
uin: number;
|
|
133
|
+
name: string;
|
|
134
|
+
content: Sendable;
|
|
135
|
+
};
|
|
132
136
|
interface MessageRet {
|
|
133
137
|
message_id: number;
|
|
134
138
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Config } from "./config";
|
|
3
2
|
import { OneBot } from "../../onebot";
|
|
4
3
|
import { Action } from "./action";
|
|
@@ -192,6 +191,11 @@ export declare namespace V12 {
|
|
|
192
191
|
interface Message {
|
|
193
192
|
message: Sendable;
|
|
194
193
|
}
|
|
194
|
+
type MessageNode = {
|
|
195
|
+
uin: number;
|
|
196
|
+
name: string;
|
|
197
|
+
content: Sendable;
|
|
198
|
+
};
|
|
195
199
|
interface Message {
|
|
196
200
|
}
|
|
197
201
|
interface MessageRet {
|
package/lib/service.d.ts
CHANGED
package/lib/service.js
CHANGED
|
@@ -74,7 +74,7 @@ exports.Service = Service;
|
|
|
74
74
|
value.length === 2 &&
|
|
75
75
|
value.every(item => typeof item === "number")) {
|
|
76
76
|
const [start, end] = value;
|
|
77
|
-
return event >= start && event <= end;
|
|
77
|
+
return Number(event) >= start && Number(event) <= end;
|
|
78
78
|
}
|
|
79
79
|
if (Array.isArray(value)) {
|
|
80
80
|
return value.includes(event[key]);
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -23,7 +23,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.version = void 0;
|
|
27
|
+
exports.readLine = readLine;
|
|
28
|
+
exports.deepMerge = deepMerge;
|
|
29
|
+
exports.transformObj = transformObj;
|
|
30
|
+
exports.deepClone = deepClone;
|
|
31
|
+
exports.pick = pick;
|
|
32
|
+
exports.omit = omit;
|
|
33
|
+
exports.toLine = toLine;
|
|
34
|
+
exports.Mixin = Mixin;
|
|
35
|
+
exports.toHump = toHump;
|
|
36
|
+
exports.remove = remove;
|
|
37
|
+
exports.toBool = toBool;
|
|
38
|
+
exports.uuid = uuid;
|
|
39
|
+
exports.randomInt = randomInt;
|
|
40
|
+
exports.protectedFields = protectedFields;
|
|
41
|
+
exports.getProperties = getProperties;
|
|
42
|
+
exports.setValueToObj = setValueToObj;
|
|
43
|
+
exports.getValueOfObj = getValueOfObj;
|
|
44
|
+
exports.getDataKeyOfObj = getDataKeyOfObj;
|
|
45
|
+
exports.parseObjFromStr = parseObjFromStr;
|
|
46
|
+
exports.stringifyObj = stringifyObj;
|
|
27
47
|
const crypto = __importStar(require("crypto"));
|
|
28
48
|
const fs = __importStar(require("fs"));
|
|
29
49
|
const readline = __importStar(require("readline"));
|
|
@@ -47,7 +67,6 @@ function readLine(maxLen, ...params) {
|
|
|
47
67
|
rl.on("error", reject);
|
|
48
68
|
});
|
|
49
69
|
}
|
|
50
|
-
exports.readLine = readLine;
|
|
51
70
|
// 合并对象/数组
|
|
52
71
|
function deepMerge(base, ...from) {
|
|
53
72
|
if (base === null || base === undefined)
|
|
@@ -78,7 +97,6 @@ function deepMerge(base, ...from) {
|
|
|
78
97
|
}
|
|
79
98
|
return base;
|
|
80
99
|
}
|
|
81
|
-
exports.deepMerge = deepMerge;
|
|
82
100
|
function transformObj(obj, callback) {
|
|
83
101
|
if (!obj)
|
|
84
102
|
return obj;
|
|
@@ -90,7 +108,6 @@ function transformObj(obj, callback) {
|
|
|
90
108
|
return [key, callback(key, obj[key])];
|
|
91
109
|
}));
|
|
92
110
|
}
|
|
93
|
-
exports.transformObj = transformObj;
|
|
94
111
|
// 深拷贝
|
|
95
112
|
function deepClone(obj) {
|
|
96
113
|
if (typeof obj !== "object")
|
|
@@ -113,7 +130,6 @@ function deepClone(obj) {
|
|
|
113
130
|
}
|
|
114
131
|
return objClone;
|
|
115
132
|
}
|
|
116
|
-
exports.deepClone = deepClone;
|
|
117
133
|
function pick(source, keys, forced) {
|
|
118
134
|
if (!keys)
|
|
119
135
|
return { ...source };
|
|
@@ -124,7 +140,6 @@ function pick(source, keys, forced) {
|
|
|
124
140
|
}
|
|
125
141
|
return result;
|
|
126
142
|
}
|
|
127
|
-
exports.pick = pick;
|
|
128
143
|
function omit(source, keys) {
|
|
129
144
|
if (!keys)
|
|
130
145
|
return { ...source };
|
|
@@ -134,7 +149,6 @@ function omit(source, keys) {
|
|
|
134
149
|
}
|
|
135
150
|
return result;
|
|
136
151
|
}
|
|
137
|
-
exports.omit = omit;
|
|
138
152
|
/**
|
|
139
153
|
* 将驼峰命名替换为下划线分割命名
|
|
140
154
|
* @param name
|
|
@@ -144,7 +158,6 @@ exports.omit = omit;
|
|
|
144
158
|
function toLine(name) {
|
|
145
159
|
return name.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
146
160
|
}
|
|
147
|
-
exports.toLine = toLine;
|
|
148
161
|
function Mixin(base, ...classes) {
|
|
149
162
|
classes.forEach(ctr => {
|
|
150
163
|
Object.getOwnPropertyNames(ctr.prototype).forEach(name => {
|
|
@@ -155,25 +168,21 @@ function Mixin(base, ...classes) {
|
|
|
155
168
|
});
|
|
156
169
|
return base;
|
|
157
170
|
}
|
|
158
|
-
exports.Mixin = Mixin;
|
|
159
171
|
function toHump(action) {
|
|
160
172
|
return action.replace(/_[\w]/g, s => {
|
|
161
173
|
return s[1].toUpperCase();
|
|
162
174
|
});
|
|
163
175
|
}
|
|
164
|
-
exports.toHump = toHump;
|
|
165
176
|
function remove(list, item) {
|
|
166
177
|
const idx = list.indexOf(item);
|
|
167
178
|
if (idx !== -1)
|
|
168
179
|
list.splice(idx, 1);
|
|
169
180
|
}
|
|
170
|
-
exports.remove = remove;
|
|
171
181
|
function toBool(v) {
|
|
172
182
|
if (v === "0" || v === "false")
|
|
173
183
|
v = false;
|
|
174
184
|
return Boolean(v);
|
|
175
185
|
}
|
|
176
|
-
exports.toBool = toBool;
|
|
177
186
|
function uuid() {
|
|
178
187
|
let hex = crypto.randomBytes(16).toString("hex");
|
|
179
188
|
return (hex.substr(0, 8) +
|
|
@@ -186,14 +195,12 @@ function uuid() {
|
|
|
186
195
|
"-" +
|
|
187
196
|
hex.substr(20));
|
|
188
197
|
}
|
|
189
|
-
exports.uuid = uuid;
|
|
190
198
|
function randomInt(...args) {
|
|
191
199
|
let min = args[0] || 0, max = args[1];
|
|
192
200
|
if (args.length === 1)
|
|
193
201
|
(max = min), (min = 0);
|
|
194
202
|
return Math.floor(Math.random() * (max - min) + min);
|
|
195
203
|
}
|
|
196
|
-
exports.randomInt = randomInt;
|
|
197
204
|
function protectedFields(source, ...keys) {
|
|
198
205
|
const protocolValue = value => {
|
|
199
206
|
if (value && typeof value === "object")
|
|
@@ -211,7 +218,6 @@ function protectedFields(source, ...keys) {
|
|
|
211
218
|
return [key, keys.includes(key) ? protocolValue(value) : value];
|
|
212
219
|
}));
|
|
213
220
|
}
|
|
214
|
-
exports.protectedFields = protectedFields;
|
|
215
221
|
function getProperties(obj) {
|
|
216
222
|
if (obj.__proto__ === null) {
|
|
217
223
|
//说明该对象已经是最顶层的对象
|
|
@@ -219,7 +225,6 @@ function getProperties(obj) {
|
|
|
219
225
|
}
|
|
220
226
|
return Object.getOwnPropertyNames(obj).concat(getProperties(obj.__proto__));
|
|
221
227
|
}
|
|
222
|
-
exports.getProperties = getProperties;
|
|
223
228
|
function setValueToObj(obj, key, value) {
|
|
224
229
|
const keys = Array.isArray(key) ? key : key.split(".").filter(Boolean);
|
|
225
230
|
const lastKey = keys.pop();
|
|
@@ -233,7 +238,6 @@ function setValueToObj(obj, key, value) {
|
|
|
233
238
|
}
|
|
234
239
|
return Reflect.set(obj, lastKey, value);
|
|
235
240
|
}
|
|
236
|
-
exports.setValueToObj = setValueToObj;
|
|
237
241
|
function getValueOfObj(obj, key) {
|
|
238
242
|
const keys = Array.isArray(key) ? key : key.split(".").filter(Boolean);
|
|
239
243
|
const lastKey = keys.pop();
|
|
@@ -247,7 +251,6 @@ function getValueOfObj(obj, key) {
|
|
|
247
251
|
}
|
|
248
252
|
return Reflect.get(obj, lastKey);
|
|
249
253
|
}
|
|
250
|
-
exports.getValueOfObj = getValueOfObj;
|
|
251
254
|
function getDataKeyOfObj(data, obj) {
|
|
252
255
|
const _get = (data, obj, prefix) => {
|
|
253
256
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -262,7 +265,6 @@ function getDataKeyOfObj(data, obj) {
|
|
|
262
265
|
};
|
|
263
266
|
return _get(data, obj, []);
|
|
264
267
|
}
|
|
265
|
-
exports.getDataKeyOfObj = getDataKeyOfObj;
|
|
266
268
|
function parseObjFromStr(str) {
|
|
267
269
|
const result = JSON.parse(str);
|
|
268
270
|
const format = (data, keys) => {
|
|
@@ -280,7 +282,6 @@ function parseObjFromStr(str) {
|
|
|
280
282
|
format(result, []);
|
|
281
283
|
return result;
|
|
282
284
|
}
|
|
283
|
-
exports.parseObjFromStr = parseObjFromStr;
|
|
284
285
|
function stringifyObj(value) {
|
|
285
286
|
if (!value || typeof value !== "object")
|
|
286
287
|
return value;
|
|
@@ -311,4 +312,3 @@ function stringifyObj(value) {
|
|
|
311
312
|
_stringify(value, []);
|
|
312
313
|
return JSON.stringify(result, (_, v) => (typeof v === "bigint" ? v.toString() : v), 2);
|
|
313
314
|
}
|
|
314
|
-
exports.stringifyObj = stringifyObj;
|