onebots 0.4.47 → 0.4.49
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-yG7HG4Oa.css → index-2tNhvoZy.css} +1 -1
- package/dist/assets/index-_Kz1yWe8.js +19 -0
- package/dist/index.html +2 -2
- package/lib/adapter.js +6 -8
- package/lib/adapters/dingtalk/index.d.ts +4 -4
- package/lib/adapters/dingtalk/index.js +56 -49
- package/lib/adapters/dingtalk/utils.js +5 -20
- package/lib/adapters/icqq/index.d.ts +5 -3
- package/lib/adapters/icqq/index.js +134 -101
- package/lib/adapters/icqq/utils.js +2 -2
- package/lib/adapters/qq/index.d.ts +4 -4
- package/lib/adapters/qq/index.js +63 -52
- package/lib/adapters/qq/utils.js +5 -20
- package/lib/adapters/wechat/index.d.ts +3 -3
- package/lib/adapters/wechat/index.js +63 -52
- package/lib/adapters/wechat/utils.js +5 -20
- package/lib/bin.js +6 -6
- package/lib/db.js +10 -10
- package/lib/onebot.d.ts +12 -12
- package/lib/onebot.js +25 -16
- package/lib/server/app.d.ts +2 -2
- package/lib/server/app.js +71 -70
- package/lib/server/router.d.ts +1 -1
- package/lib/server/router.js +5 -5
- package/lib/service/V11/action/common.d.ts +1 -0
- package/lib/service/V11/action/common.js +24 -24
- package/lib/service/V11/action/friend.js +16 -8
- package/lib/service/V11/action/group.js +52 -22
- package/lib/service/V11/index.js +86 -50
- package/lib/service/V12/action/common.d.ts +3 -3
- package/lib/service/V12/action/common.js +33 -31
- package/lib/service/V12/action/friend.js +8 -4
- package/lib/service/V12/action/group.js +50 -20
- package/lib/service/V12/action/guild.js +110 -35
- package/lib/service/V12/index.d.ts +18 -18
- package/lib/service/V12/index.js +189 -147
- package/lib/service/shareMusicCustom.js +14 -9
- package/lib/service.js +29 -27
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +44 -32
- package/package.json +1 -1
- package/dist/assets/index-YN4djyjB.js +0 -19
|
@@ -53,50 +53,57 @@ async function processMessages(uin, target_id, target_type, list) {
|
|
|
53
53
|
for (const item of list) {
|
|
54
54
|
const { type, data, ...other } = item;
|
|
55
55
|
switch (type) {
|
|
56
|
-
case
|
|
56
|
+
case "node": {
|
|
57
57
|
result.push({
|
|
58
58
|
type,
|
|
59
59
|
...data,
|
|
60
|
-
message: await processMessages.call(this, uin, data.user_id,
|
|
60
|
+
message: await processMessages.call(this, uin, data.user_id, "private", data.content || []),
|
|
61
61
|
});
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
|
-
case
|
|
65
|
-
if (String(item.data.platform) ===
|
|
66
|
-
item.data.platform = item.data[
|
|
64
|
+
case "music": {
|
|
65
|
+
if (String(item.data.platform) === "custom") {
|
|
66
|
+
item.data.platform = item.data["subtype"]; // gocq 的平台数据存储在 subtype 内,兼容 icqq 时要求前端必须发送 id 字段
|
|
67
67
|
}
|
|
68
68
|
const { type, data } = item;
|
|
69
|
-
await shareMusicCustom_1.shareMusic.call(this[target_type ===
|
|
69
|
+
await shareMusicCustom_1.shareMusic.call(this[target_type === "private" ? "pickFriend" : "pickGroup"](target_id), {
|
|
70
70
|
type,
|
|
71
|
-
...data
|
|
71
|
+
...data,
|
|
72
72
|
});
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
|
-
case
|
|
76
|
-
await this[target_type ===
|
|
75
|
+
case "share": {
|
|
76
|
+
await this[target_type === "private" ? "pickFriend" : "pickGroup"](target_id).shareUrl(item.data);
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
|
-
case
|
|
80
|
-
case
|
|
81
|
-
case
|
|
82
|
-
if (item[
|
|
83
|
-
item[
|
|
84
|
-
if (item[
|
|
85
|
-
item[
|
|
79
|
+
case "video":
|
|
80
|
+
case "audio":
|
|
81
|
+
case "image": {
|
|
82
|
+
if (item["file_id"]?.startsWith("base64://"))
|
|
83
|
+
item["file_id"] = Buffer.from(item["file_id"].slice(9), "base64");
|
|
84
|
+
if (item["file"]?.startsWith("base64://"))
|
|
85
|
+
item["file"] = Buffer.from(item["file"].slice(9), "base64");
|
|
86
86
|
result.push({
|
|
87
87
|
type,
|
|
88
88
|
...data,
|
|
89
|
-
...other
|
|
89
|
+
...other,
|
|
90
90
|
});
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
|
-
case
|
|
93
|
+
case "reply": {
|
|
94
94
|
const oneBot = this.getOneBot(uin);
|
|
95
|
-
const message_id = oneBot.V11.getStrByInt(
|
|
95
|
+
const message_id = oneBot.V11.getStrByInt("message_id", data.id);
|
|
96
96
|
const msg = await oneBot.internal.getMsg(message_id);
|
|
97
97
|
result.push({
|
|
98
|
-
type:
|
|
99
|
-
...msg
|
|
98
|
+
type: "quote",
|
|
99
|
+
...msg,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
case "text": {
|
|
103
|
+
result.push({
|
|
104
|
+
type,
|
|
105
|
+
...data,
|
|
106
|
+
...other,
|
|
100
107
|
});
|
|
101
108
|
}
|
|
102
109
|
}
|
|
@@ -105,7 +112,7 @@ async function processMessages(uin, target_id, target_type, list) {
|
|
|
105
112
|
}
|
|
106
113
|
class IcqqAdapter extends adapter_1.Adapter {
|
|
107
114
|
constructor(app, config) {
|
|
108
|
-
super(app,
|
|
115
|
+
super(app, "icqq", config);
|
|
109
116
|
_IcqqAdapter_password.set(this, void 0);
|
|
110
117
|
_IcqqAdapter_disposes.set(this, new Map());
|
|
111
118
|
this.icon = `https://qzonestyle.gtimg.cn/qzone/qzact/act/external/tiqq/logo.png`;
|
|
@@ -113,26 +120,40 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
113
120
|
async setOnline(uin) {
|
|
114
121
|
const oneBot = this.getOneBot(uin);
|
|
115
122
|
if (!oneBot)
|
|
116
|
-
throw new Error(
|
|
123
|
+
throw new Error("No one");
|
|
117
124
|
await oneBot.internal.login(parseInt(uin), __classPrivateFieldGet(this, _IcqqAdapter_password, "f"));
|
|
118
125
|
}
|
|
119
126
|
async setOffline(uin) {
|
|
120
127
|
const oneBot = this.getOneBot(uin);
|
|
121
128
|
if (!oneBot)
|
|
122
|
-
throw new Error(
|
|
129
|
+
throw new Error("No one");
|
|
123
130
|
await oneBot.internal.logout();
|
|
124
131
|
oneBot.status = onebot_1.OneBotStatus.Bad;
|
|
125
132
|
}
|
|
133
|
+
getMessage(uin, version) {
|
|
134
|
+
const oneBot = this.getOneBot(uin);
|
|
135
|
+
if (!oneBot)
|
|
136
|
+
throw new Error("No one");
|
|
137
|
+
return oneBot.internal.getMsg(version);
|
|
138
|
+
}
|
|
139
|
+
callApi(uin, version, [name, args]) {
|
|
140
|
+
const oneBot = this.getOneBot(uin);
|
|
141
|
+
if (!oneBot)
|
|
142
|
+
throw new Error("No one");
|
|
143
|
+
if (!oneBot.internal[name])
|
|
144
|
+
throw new Error(`internal no api ${name}`);
|
|
145
|
+
return oneBot[version][name](...args);
|
|
146
|
+
}
|
|
126
147
|
createOneBot(uin, protocol, versions) {
|
|
127
148
|
const oneBot = super.createOneBot(uin, protocol, versions);
|
|
128
149
|
__classPrivateFieldSet(this, _IcqqAdapter_password, this.app.config[`icqq.${uin}`].password, "f");
|
|
129
150
|
oneBot.avatar = `https://q1.qlogo.cn/g?b=qq&s=100&nk=` + uin;
|
|
130
|
-
const pkg = require(path.resolve(path.dirname(require.resolve(
|
|
151
|
+
const pkg = require(path.resolve(path.dirname(require.resolve("icqq")), "../package.json"));
|
|
131
152
|
oneBot.dependency = `icqq v${pkg.version}`;
|
|
132
153
|
oneBot.status = onebot_1.OneBotStatus.Online;
|
|
133
154
|
oneBot.internal = new icqq_1.Client((0, utils_1.deepMerge)(protocol, (0, utils_1.deepClone)({
|
|
134
155
|
...exports.defaultIcqqConfig,
|
|
135
|
-
log_level: this.app.config.log_level
|
|
156
|
+
log_level: this.app.config.log_level,
|
|
136
157
|
})));
|
|
137
158
|
return oneBot;
|
|
138
159
|
}
|
|
@@ -143,23 +164,26 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
143
164
|
type: event,
|
|
144
165
|
version: version,
|
|
145
166
|
self: {
|
|
146
|
-
platform:
|
|
147
|
-
user_id: data.self_id
|
|
167
|
+
platform: "qq",
|
|
168
|
+
user_id: data.self_id,
|
|
148
169
|
},
|
|
149
170
|
detail_type: data.message_type || data.notice_type || data.request_type,
|
|
150
|
-
platform:
|
|
171
|
+
platform: "qq",
|
|
151
172
|
...data,
|
|
152
173
|
};
|
|
153
174
|
if (data.source) {
|
|
154
|
-
const message_id = data.message_type ===
|
|
155
|
-
(0, message_1.
|
|
175
|
+
const message_id = data.message_type === "group"
|
|
176
|
+
? (0, message_1.genGroupMessageId)(data.group_id, data.sender.user_id, data.source?.seq, data.source?.rand, data.source?.time, data.source?.pktnum)
|
|
177
|
+
: (0, message_1.genDmMessageId)(data.sender.user_id, data.source?.seq, data.source?.rand, data.source?.time);
|
|
156
178
|
data.message[0] = {
|
|
157
|
-
type:
|
|
158
|
-
id: version ===
|
|
179
|
+
type: "reply",
|
|
180
|
+
id: version === "V11"
|
|
181
|
+
? oneBot.V11.transformToInt("message_id", message_id)
|
|
182
|
+
: message_id,
|
|
159
183
|
};
|
|
160
184
|
}
|
|
161
|
-
if (version ===
|
|
162
|
-
result.message_id = oneBot.V11.transformToInt(
|
|
185
|
+
if (version === "V11" && result.message_id) {
|
|
186
|
+
result.message_id = oneBot.V11.transformToInt("message_id", result.message_id);
|
|
163
187
|
}
|
|
164
188
|
return result;
|
|
165
189
|
}
|
|
@@ -169,9 +193,11 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
169
193
|
let quote;
|
|
170
194
|
if (source)
|
|
171
195
|
quote = await client.getMsg(source);
|
|
172
|
-
const result = await client.sendPrivateMsg(parseInt(user_id), await processMessages.call(this, uin, user_id,
|
|
196
|
+
const result = await client.sendPrivateMsg(parseInt(user_id), await processMessages.call(this, uin, user_id, "private", message), quote);
|
|
173
197
|
return {
|
|
174
|
-
message_id: version ===
|
|
198
|
+
message_id: version === "V11"
|
|
199
|
+
? this.oneBots.get(uin).V11.transformToInt("message_id", result.message_id)
|
|
200
|
+
: result.message_id,
|
|
175
201
|
};
|
|
176
202
|
}
|
|
177
203
|
deleteMessage(uin, version, args) {
|
|
@@ -184,19 +210,23 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
184
210
|
let quote;
|
|
185
211
|
if (source)
|
|
186
212
|
quote = await client.getMsg(source);
|
|
187
|
-
const result = await client.sendGroupMsg(parseInt(group_id), await processMessages.call(this, group_id,
|
|
213
|
+
const result = await client.sendGroupMsg(parseInt(group_id), await processMessages.call(this, uin, group_id, "group", message), quote);
|
|
188
214
|
return {
|
|
189
|
-
message_id: version ===
|
|
215
|
+
message_id: version === "V11"
|
|
216
|
+
? this.oneBots.get(uin).V11.transformToInt("message_id", result.message_id)
|
|
217
|
+
: result.message_id,
|
|
190
218
|
};
|
|
191
219
|
}
|
|
192
220
|
async sendGuildMessage(uin, version, args) {
|
|
193
221
|
const [target_id, message, source] = args;
|
|
194
222
|
const client = this.oneBots.get(uin)?.internal;
|
|
195
|
-
const [guild_id, channel_id] = target_id.split(
|
|
196
|
-
const result = await client.sendGuildMsg(guild_id, channel_id, await processMessages.call(this, target_id,
|
|
223
|
+
const [guild_id, channel_id] = target_id.split(":");
|
|
224
|
+
const result = await client.sendGuildMsg(guild_id, channel_id, await processMessages.call(this, uin, target_id, "channel", message));
|
|
197
225
|
const message_id = `${result.seq}:${result.rand}:${result.time}`;
|
|
198
226
|
return {
|
|
199
|
-
message_id: version ===
|
|
227
|
+
message_id: version === "V11"
|
|
228
|
+
? this.oneBots.get(uin).V11.transformToInt("message_id", message_id)
|
|
229
|
+
: message_id,
|
|
200
230
|
};
|
|
201
231
|
}
|
|
202
232
|
call(uin, version, method, args = []) {
|
|
@@ -213,27 +243,27 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
213
243
|
return [].concat(segment).map(item => {
|
|
214
244
|
if (typeof item === "string")
|
|
215
245
|
return {
|
|
216
|
-
type:
|
|
246
|
+
type: "text",
|
|
217
247
|
data: {
|
|
218
|
-
text: item
|
|
219
|
-
}
|
|
248
|
+
text: item,
|
|
249
|
+
},
|
|
220
250
|
};
|
|
221
251
|
return item;
|
|
222
252
|
});
|
|
223
253
|
}
|
|
224
254
|
toSegment(version, message) {
|
|
225
255
|
return [].concat(message).map(item => {
|
|
226
|
-
if (typeof item !==
|
|
256
|
+
if (typeof item !== "object")
|
|
227
257
|
item = {
|
|
228
|
-
type:
|
|
258
|
+
type: "text",
|
|
229
259
|
data: {
|
|
230
|
-
text: item
|
|
231
|
-
}
|
|
260
|
+
text: item,
|
|
261
|
+
},
|
|
232
262
|
};
|
|
233
263
|
const { type, ...data } = item;
|
|
234
264
|
return {
|
|
235
265
|
type,
|
|
236
|
-
data
|
|
266
|
+
data,
|
|
237
267
|
};
|
|
238
268
|
});
|
|
239
269
|
}
|
|
@@ -242,11 +272,11 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
242
272
|
if (!regExpMatchArray)
|
|
243
273
|
return [
|
|
244
274
|
{
|
|
245
|
-
type:
|
|
275
|
+
type: "text",
|
|
246
276
|
data: {
|
|
247
|
-
text: message
|
|
248
|
-
}
|
|
249
|
-
}
|
|
277
|
+
text: message,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
250
280
|
];
|
|
251
281
|
const result = [];
|
|
252
282
|
while (message.length) {
|
|
@@ -256,53 +286,56 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
256
286
|
const prevText = message.substring(0, match.length);
|
|
257
287
|
if (prevText) {
|
|
258
288
|
result.push({
|
|
259
|
-
type:
|
|
289
|
+
type: "text",
|
|
260
290
|
data: {
|
|
261
|
-
text: prevText
|
|
262
|
-
}
|
|
291
|
+
text: prevText,
|
|
292
|
+
},
|
|
263
293
|
});
|
|
264
294
|
}
|
|
265
|
-
const [type, ...valueArr] = match.substring(1, match.length - 1).split(
|
|
295
|
+
const [type, ...valueArr] = match.substring(1, match.length - 1).split(",");
|
|
266
296
|
result.push({
|
|
267
297
|
type: type,
|
|
268
298
|
data: Object.fromEntries(valueArr.map(item => {
|
|
269
|
-
const [key, value] = item.split(
|
|
299
|
+
const [key, value] = item.split("=");
|
|
270
300
|
return [key, value];
|
|
271
|
-
}))
|
|
301
|
+
})),
|
|
272
302
|
});
|
|
273
303
|
message = message.substring(match.length);
|
|
274
304
|
}
|
|
275
305
|
if (message.length) {
|
|
276
306
|
result.push({
|
|
277
|
-
type:
|
|
307
|
+
type: "text",
|
|
278
308
|
data: {
|
|
279
|
-
text: message
|
|
280
|
-
}
|
|
309
|
+
text: message,
|
|
310
|
+
},
|
|
281
311
|
});
|
|
282
312
|
}
|
|
283
313
|
return result;
|
|
284
314
|
}
|
|
285
315
|
toCqcode(version, messageArr) {
|
|
286
|
-
return []
|
|
316
|
+
return []
|
|
317
|
+
.concat(messageArr)
|
|
318
|
+
.map(item => {
|
|
287
319
|
if (typeof item === "string")
|
|
288
320
|
return item;
|
|
289
|
-
if (item.type ===
|
|
321
|
+
if (item.type === "text")
|
|
290
322
|
return item.data?.text || item.text;
|
|
291
323
|
const dataStr = Object.entries(item.data || item).map(([key, value]) => {
|
|
292
324
|
// is Buffer
|
|
293
325
|
if (value instanceof Buffer)
|
|
294
|
-
return `${key}=${value.toString(
|
|
326
|
+
return `${key}=${value.toString("base64")}`;
|
|
295
327
|
// is Object
|
|
296
328
|
if (value instanceof Object)
|
|
297
329
|
return `${key}=${JSON.stringify(value)}`;
|
|
298
330
|
// is Array
|
|
299
331
|
if (value instanceof Array)
|
|
300
|
-
return `${key}=${value.map(v => JSON.stringify(v)).join(
|
|
332
|
+
return `${key}=${value.map(v => JSON.stringify(v)).join(",")}`;
|
|
301
333
|
// is String
|
|
302
334
|
return `${key}=${item.data?.[key] || item[key]}`;
|
|
303
335
|
});
|
|
304
|
-
return `[CQ:${item.type},${dataStr.join(
|
|
305
|
-
})
|
|
336
|
+
return `[CQ:${item.type},${dataStr.join(",")}]`;
|
|
337
|
+
})
|
|
338
|
+
.join("");
|
|
306
339
|
}
|
|
307
340
|
getSelfInfo(uin, version) {
|
|
308
341
|
const client = this.oneBots.get(uin).internal;
|
|
@@ -315,62 +348,62 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
315
348
|
const _this = this;
|
|
316
349
|
const disposeArr = [];
|
|
317
350
|
const client = oneBot.internal;
|
|
318
|
-
client.trap(
|
|
319
|
-
_this.logger.log(
|
|
320
|
-
process_1.default.stdin.once(
|
|
351
|
+
client.trap("system.login.qrcode", function qrcodeHelper() {
|
|
352
|
+
_this.logger.log("扫码后回车继续");
|
|
353
|
+
process_1.default.stdin.once("data", () => {
|
|
321
354
|
this.login();
|
|
322
355
|
});
|
|
323
356
|
disposeArr.push(() => {
|
|
324
|
-
this.off(
|
|
357
|
+
this.off("system.login.qrcode", qrcodeHelper);
|
|
325
358
|
});
|
|
326
359
|
});
|
|
327
|
-
client.trap(
|
|
328
|
-
_this.logger.mark(
|
|
329
|
-
process_1.default.stdin.once(
|
|
360
|
+
client.trap("system.login.device", function deviceHelper(e) {
|
|
361
|
+
_this.logger.mark("请选择验证方式:1.短信验证 2.url验证");
|
|
362
|
+
process_1.default.stdin.once("data", buf => {
|
|
330
363
|
const input = buf.toString().trim();
|
|
331
|
-
if (input ===
|
|
364
|
+
if (input === "1") {
|
|
332
365
|
this.sendSmsCode();
|
|
333
|
-
_this.logger.mark(
|
|
334
|
-
const terminalInputHandler =
|
|
366
|
+
_this.logger.mark("请输入短信验证码:");
|
|
367
|
+
const terminalInputHandler = buf => {
|
|
335
368
|
client.submitSmsCode(buf.toString().trim());
|
|
336
369
|
};
|
|
337
|
-
process_1.default.stdin.once(
|
|
370
|
+
process_1.default.stdin.once("data", terminalInputHandler);
|
|
338
371
|
}
|
|
339
372
|
else {
|
|
340
373
|
_this.logger.mark(`请前往:${e.url} 完成验证后回车继续`);
|
|
341
374
|
const terminalInputHandler = () => {
|
|
342
375
|
client.login();
|
|
343
376
|
};
|
|
344
|
-
process_1.default.stdin.once(
|
|
377
|
+
process_1.default.stdin.once("data", terminalInputHandler);
|
|
345
378
|
}
|
|
346
379
|
});
|
|
347
380
|
disposeArr.push(() => {
|
|
348
|
-
this.off(
|
|
381
|
+
this.off("system.login.device", deviceHelper);
|
|
349
382
|
});
|
|
350
383
|
});
|
|
351
|
-
client.trap(
|
|
352
|
-
_this.logger.mark(
|
|
353
|
-
process_1.default.stdin.once(
|
|
384
|
+
client.trap("system.login.slider", function sliderHelper(e) {
|
|
385
|
+
_this.logger.mark("请输入滑块验证返回的ticket");
|
|
386
|
+
process_1.default.stdin.once("data", e => {
|
|
354
387
|
this.submitSlider(e.toString().trim());
|
|
355
388
|
});
|
|
356
389
|
disposeArr.push(() => {
|
|
357
|
-
this.off(
|
|
390
|
+
this.off("system.login.slider", sliderHelper);
|
|
358
391
|
});
|
|
359
392
|
});
|
|
360
|
-
disposeArr.push(client.on(
|
|
361
|
-
this.emit(
|
|
393
|
+
disposeArr.push(client.on("message", event => {
|
|
394
|
+
this.emit("message.receive", oneBot.uin, event);
|
|
362
395
|
}));
|
|
363
|
-
disposeArr.push(client.on(
|
|
364
|
-
this.emit(
|
|
396
|
+
disposeArr.push(client.on("notice", event => {
|
|
397
|
+
this.emit("notice.receive", oneBot.uin, event);
|
|
365
398
|
}));
|
|
366
|
-
disposeArr.push(client.on(
|
|
367
|
-
this.emit(
|
|
399
|
+
disposeArr.push(client.on("request", event => {
|
|
400
|
+
this.emit("request.receive", oneBot.uin, event);
|
|
368
401
|
}));
|
|
369
402
|
this.setOnline(oneBot.uin);
|
|
370
403
|
return new Promise((resolve, reject) => {
|
|
371
|
-
client.trap(
|
|
372
|
-
if (e.message.includes(
|
|
373
|
-
process_1.default.stdin.once(
|
|
404
|
+
client.trap("system.login.error", function errorHandler(e) {
|
|
405
|
+
if (e.message.includes("密码错误")) {
|
|
406
|
+
process_1.default.stdin.once("data", e => {
|
|
374
407
|
this.login(e.toString().trim());
|
|
375
408
|
});
|
|
376
409
|
}
|
|
@@ -379,7 +412,7 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
379
412
|
oneBot.status = onebot_1.OneBotStatus.Bad;
|
|
380
413
|
clean();
|
|
381
414
|
}
|
|
382
|
-
this.off(
|
|
415
|
+
this.off("system.login.error", errorHandler);
|
|
383
416
|
});
|
|
384
417
|
const clean = () => {
|
|
385
418
|
clearTimeout(timer);
|
|
@@ -387,13 +420,13 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
387
420
|
disposeArr.shift()();
|
|
388
421
|
}
|
|
389
422
|
};
|
|
390
|
-
client.trap(
|
|
423
|
+
client.trap("system.online", () => {
|
|
391
424
|
oneBot.nickname = client.nickname;
|
|
392
425
|
oneBot.status = onebot_1.OneBotStatus.Good;
|
|
393
426
|
this.app.ws.clients.forEach(client => {
|
|
394
427
|
client.send(JSON.stringify({
|
|
395
|
-
event:
|
|
396
|
-
data: oneBot.info
|
|
428
|
+
event: "bot.change",
|
|
429
|
+
data: oneBot.info,
|
|
397
430
|
}));
|
|
398
431
|
});
|
|
399
432
|
clearTimeout(timer);
|
|
@@ -402,7 +435,7 @@ class IcqqAdapter extends adapter_1.Adapter {
|
|
|
402
435
|
const timer = setTimeout(() => {
|
|
403
436
|
oneBot.status = onebot_1.OneBotStatus.Bad;
|
|
404
437
|
clean();
|
|
405
|
-
reject(
|
|
438
|
+
reject("登录超时");
|
|
406
439
|
}, this.app.config.timeout * 1000);
|
|
407
440
|
});
|
|
408
441
|
}
|
|
@@ -435,5 +468,5 @@ _IcqqAdapter_password = new WeakMap(), _IcqqAdapter_disposes = new WeakMap();
|
|
|
435
468
|
exports.default = IcqqAdapter;
|
|
436
469
|
exports.defaultIcqqConfig = {
|
|
437
470
|
platform: 2,
|
|
438
|
-
data_dir: path.join(process_1.default.cwd(),
|
|
471
|
+
data_dir: path.join(process_1.default.cwd(), "data"),
|
|
439
472
|
};
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.processMessage = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
async function processMessage(elements) {
|
|
6
|
-
let music = elements.find(
|
|
6
|
+
let music = elements.find(e => e.type === "music");
|
|
7
7
|
if (music) {
|
|
8
8
|
(0, utils_1.remove)(elements, music);
|
|
9
9
|
if (String(music.platform) === "custom") {
|
|
10
10
|
music.platform = music["subtype"]; // gocq 的平台数据存储在 subtype 内,兼容 icqq 时要求前端必须发送 id 字段
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
let share = elements.find(
|
|
13
|
+
let share = elements.find(e => e.type === "share");
|
|
14
14
|
if (share)
|
|
15
15
|
(0, utils_1.remove)(elements, share);
|
|
16
16
|
for (const element of elements) {
|
|
@@ -2,7 +2,7 @@ import { Adapter } from "../../adapter";
|
|
|
2
2
|
import { App } from "../../server/app";
|
|
3
3
|
import { OneBot } from "../../onebot";
|
|
4
4
|
import { Bot, Sendable } from "qq-group-bot";
|
|
5
|
-
export default class QQAdapter extends Adapter<
|
|
5
|
+
export default class QQAdapter extends Adapter<"qq"> {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(app: App, config: QQAdapter.Config);
|
|
8
8
|
startOneBot(oneBot: OneBot<Bot>): Promise<() => void>;
|
|
@@ -24,7 +24,7 @@ export default class QQAdapter extends Adapter<'qq'> {
|
|
|
24
24
|
stop(uin?: string): Promise<void>;
|
|
25
25
|
getSelfInfo<V extends OneBot.Version>(uin: string, version: V): OneBot.SelfInfo<V>;
|
|
26
26
|
}
|
|
27
|
-
declare module
|
|
27
|
+
declare module "../../adapter" {
|
|
28
28
|
namespace Adapter {
|
|
29
29
|
interface Configs {
|
|
30
30
|
qq: QQAdapter.Config;
|
|
@@ -32,7 +32,7 @@ declare module '../../adapter' {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
export declare namespace QQAdapter {
|
|
35
|
-
interface Config extends Adapter.Config<
|
|
36
|
-
protocol: Omit<Bot.Config,
|
|
35
|
+
interface Config extends Adapter.Config<"qq"> {
|
|
36
|
+
protocol: Omit<Bot.Config, "appid">;
|
|
37
37
|
}
|
|
38
38
|
}
|