From 17af1564519bf81fc9cbcccb8280495fbedbbfbc Mon Sep 17 00:00:00 2001 From: linyuchen Date: Sat, 9 Mar 2024 02:34:21 +0800 Subject: [PATCH] fix: update msg seqId --- src/common/db.ts | 20 +++++++++----------- src/onebot11/constructor.ts | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/common/db.ts b/src/common/db.ts index cba3ac4..220c6ad 100644 --- a/src/common/db.ts +++ b/src/common/db.ts @@ -118,11 +118,10 @@ class DBUtil { this.db.put(shortIdKey, msg.msgId).then(); this.db.put(longIdKey, JSON.stringify(msg)).then(); try { - if (!(await this.db.get(seqIdKey))) { - this.db.put(seqIdKey, msg.msgId).then(); - } + await this.db.get(seqIdKey) } catch (e) { - + // log("新的seqId", seqIdKey) + this.db.put(seqIdKey, msg.msgId).then(); } this.cache[shortIdKey] = this.cache[longIdKey] = msg; if (!this.cache[seqIdKey]) { @@ -142,7 +141,7 @@ class DBUtil { try { existMsg = await this.getMsgByLongId(msg.msgId) } catch (e) { - return + existMsg = msg } } @@ -155,11 +154,10 @@ class DBUtil { } this.db.put(shortIdKey, msg.msgId).then(); try { - if (!(await this.db.get(seqIdKey))) { - this.db.put(seqIdKey, msg.msgId).then(); - } + await this.db.get(seqIdKey) } catch (e) { - + this.db.put(seqIdKey, msg.msgId).then(); + // log("更新seqId error", e.stack, seqIdKey); } // log("更新消息", existMsg.msgSeq, existMsg.msgShortId, existMsg.msgId); } @@ -197,11 +195,11 @@ class DBUtil { if (this.cache[key]) { return this.cache[key] as FileCache } - try{ + try { let data = await this.db.get(key); return JSON.parse(data); - }catch (e) { + } catch (e) { } } diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index e3d7c6f..ab1f3fa 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -106,7 +106,7 @@ export class OB11Constructor { continue } }catch (e) { - log("获取不到引用的消息", e.stack) + log("获取不到引用的消息", e.stack, element.replyElement.replayMsgSeq) } } else if (element.picElement) { @@ -119,7 +119,7 @@ export class OB11Constructor { if (url){ message_data["data"]["url"] = IMAGE_HTTP_HOST + url } - else if (fileMd5){ + else if (fileMd5 && element.picElement.fileUuid.indexOf("_") === -1){ // fileuuid有下划线的是Linux发送的,这个url是另外的格式,目前尚未得知如何组装 message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0` } // message_data["data"]["file_id"] = element.picElement.fileUuid