From 024028a6d857858bc390d13b1dabf959452c54da Mon Sep 17 00:00:00 2001 From: takayama Date: Sat, 14 Aug 2021 15:28:31 +0900 Subject: [PATCH] release --- lib/message/builder.js | 2 +- lib/message/parser.js | 31 ++++++++++++++++++++----------- lib/onlinepush.js | 4 +++- package.json | 6 +++--- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lib/message/builder.js b/lib/message/builder.js index 20541404..6987a16d 100644 --- a/lib/message/builder.js +++ b/lib/message/builder.js @@ -18,7 +18,7 @@ const { highwayUploadStream } = require("../service"); const { parseC2CMessageId, parseGroupMessageId, genMessageUuid, genC2CMessageId, genRandom } = common; const EMOJI_NOT_ENDING = ["\uD83C", "\uD83D", "\uD83E", "\u200D"]; const EMOJI_NOT_STARTING = ["\uFE0F", "\u200D", "\u20E3"]; -const PB_CONTENT = pb.encode({ 1: 1, 2: 0, 3: 0 }); +const PB_CONTENT = pb.encode({ 1: 1, 2: 0, 3: randomBytes(2).readUInt16BE() }); const PB_RESERVER = pb.encode({ 37: { 17: 0, diff --git a/lib/message/parser.js b/lib/message/parser.js index 8f42e3f9..7afb6ca8 100644 --- a/lib/message/parser.js +++ b/lib/message/parser.js @@ -117,8 +117,22 @@ class Parser { it; atme = false; + + /** + * @public + * @param {import("../ref").Client} c + * @param {number} uid + * @param {number} gid + * @param {import("../ref").RichMsg} rich + */ + static async invoke(c, uid, gid, rich) { + const parser = new Parser(c, uid, gid) + await parser.parseMsg(rich); + return parser; + } /** + * @private * @param {import("../ref").Client} c * @param {number} uid 发送者 * @param {number} gid 群号 @@ -130,7 +144,7 @@ class Parser { } /** - * @public + * @private * @param {import("../ref").RichMsg} rich */ async parseMsg(rich) { @@ -375,8 +389,7 @@ class Parser { const buf = await _downloadMultiMsg.call(this.c, elem[7].toBuffer(), 1); let msg = pb.decode(buf)[1]; if (Array.isArray(msg)) msg = msg[0]; - const parser = new Parser(this.c, this.uid, this.gid); - await parser.parseMsg(msg[3][1]); + const parser = Parser.invoke(this.c, this.uid, this.gid, msg[3][1]); this.message = parser.message; this.raw_message = parser.raw_message; this.anonymous = parser.anonymous; @@ -586,8 +599,7 @@ async function parseC2CMsg(msg, realtime = false) { return; } } else if (body[1] && body[1][2]) { - var parser = new Parser(this, uid, 0); - await parser.parseMsg(body[1]); + var parser = await Parser.invoke(this, uid, 0, body[1]); } else { return; } @@ -626,8 +638,7 @@ async function parseGroupMsg(msg, realtime = false) { this.getGroupInfo(group_id); } - const parser = new Parser(this, user_id, group_id); - await parser.parseMsg(body[1]); + const parser = await Parser.invoke(this, user_id, group_id, body[1]); let font = String(body[1][1][9]), card = parseFunString(group[4].toBuffer()), @@ -703,8 +714,7 @@ async function parseDiscussMsg(msg) { user_id, nickname, card }; - const parser = new Parser(this, user_id, discuss_id); - await parser.parseMsg(body[1]); + const parser = await Parser.invoke(this, user_id, discuss_id, body[1]); return { discuss_id, discuss_name, user_id, @@ -745,8 +755,7 @@ async function parseForwardMsg(resid) { group_id = head[9][1]; } catch { } } - const parser = new Parser(this, user_id, group_id); - await parser.parseMsg(msg[3][1]); + const parser = await Parser.invoke(this, user_id, group_id, msg[3][1]); data.push({ group_id, user_id, nickname, time, message: parser.message, diff --git a/lib/onlinepush.js b/lib/onlinepush.js index d109d217..b270eff3 100644 --- a/lib/onlinepush.js +++ b/lib/onlinepush.js @@ -92,7 +92,9 @@ const sub0x27 = { const status = o[2].toBuffer()[o[2].toBuffer().length - 1]; const old_status = this.online_status, new_status = status_map[status] || 11; this.online_status = new_status; - return this.em("sync.status", { old_status, new_status }); + if (old_status !== new_status) + this.em("sync.status", { old_status, new_status }); + return } else { return; } diff --git a/package.json b/package.json index ea45b18c..e4b1000b 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "oicq", "app_name": "oicq", - "version": "1.18.3", - "app_version": "1.18.3", - "upday": "2021/7/22", + "version": "1.19.0", + "app_version": "1.19.0", + "upday": "2021/8/14", "protocol_version": "v11", "description": "QQ protocol!", "main": "index.js",