Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
takayama-lily committed Aug 14, 2021
1 parent cb19ec0 commit 024028a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/message/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 20 additions & 11 deletions lib/message/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 群号
Expand All @@ -130,7 +144,7 @@ class Parser {
}

/**
* @public
* @private
* @param {import("../ref").RichMsg} rich
*/
async parseMsg(rich) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion lib/onlinepush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 024028a

Please sign in to comment.