From 55d046b4f933b7c903b3f742b202d2ba4986c378 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Thu, 7 Mar 2024 14:18:24 +0800 Subject: [PATCH] fix: reply msg id --- manifest.json | 4 +- package-lock.json | 194 ++++++-------------------- src/common/data.ts | 16 +-- src/common/db.ts | 37 ++++- src/main/main.ts | 4 +- src/ntqqapi/hook.ts | 4 +- src/ntqqapi/ntcall.ts | 2 +- src/onebot11/action/BaseAction.ts | 2 +- src/onebot11/action/SendGroupMsg.ts | 10 +- src/onebot11/action/SendLike.ts | 10 +- src/onebot11/action/SendMsg.ts | 2 +- src/onebot11/action/SendPrivateMsg.ts | 8 +- src/onebot11/constructor.ts | 5 +- src/version.ts | 2 +- 14 files changed, 117 insertions(+), 183 deletions(-) diff --git a/manifest.json b/manifest.json index 9e4b419..725bfdc 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.13.2", + "name": "LLOneBot v3.13.4", "slug": "LLOneBot", "description": "LiteLoaderQQNT的OneBotApi", - "version": "3.13.2", + "version": "3.13.4", "thumbnail": "./icon.png", "authors": [ { diff --git a/package-lock.json b/package-lock.json index 44df5c1..e2030ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -986,16 +986,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "node_modules/@eslint/eslintrc/node_modules/globals": { "version": "13.24.0", "resolved": "https://mirrors.cloud.tencent.com/npm/globals/-/globals-13.24.0.tgz", @@ -1011,18 +1001,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@eslint/eslintrc/node_modules/type-fest": { "version": "0.20.2", "resolved": "https://mirrors.cloud.tencent.com/npm/type-fest/-/type-fest-0.20.2.tgz", @@ -1058,28 +1036,6 @@ "node": ">=10.10.0" } }, - "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://mirrors.cloud.tencent.com/npm/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -3225,16 +3181,6 @@ "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" } }, - "node_modules/eslint-plugin-import/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "node_modules/eslint-plugin-import/node_modules/debug": { "version": "3.2.7", "resolved": "https://mirrors.cloud.tencent.com/npm/debug/-/debug-3.2.7.tgz", @@ -3256,18 +3202,6 @@ "node": ">=0.10.0" } }, - "node_modules/eslint-plugin-import/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint-plugin-n": { "version": "16.6.2", "resolved": "https://mirrors.cloud.tencent.com/npm/eslint-plugin-n/-/eslint-plugin-n-16.6.2.tgz", @@ -3296,16 +3230,6 @@ "eslint": ">=7.0.0" } }, - "node_modules/eslint-plugin-n/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "node_modules/eslint-plugin-n/node_modules/globals": { "version": "13.24.0", "resolved": "https://mirrors.cloud.tencent.com/npm/globals/-/globals-13.24.0.tgz", @@ -3321,18 +3245,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-plugin-n/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint-plugin-n/node_modules/semver": { "version": "7.6.0", "resolved": "https://mirrors.cloud.tencent.com/npm/semver/-/semver-7.6.0.tgz", @@ -3384,16 +3296,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "node_modules/eslint/node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://mirrors.cloud.tencent.com/npm/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -3477,18 +3379,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/eslint/node_modules/p-limit": { "version": "3.1.0", "resolved": "https://mirrors.cloud.tencent.com/npm/p-limit/-/p-limit-3.1.0.tgz", @@ -4012,6 +3902,26 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://mirrors.cloud.tencent.com/npm/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -4922,6 +4832,28 @@ "node": ">=4" } }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimatch/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://mirrors.cloud.tencent.com/npm/minimist/-/minimist-1.2.8.tgz", @@ -5509,48 +5441,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rimraf/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://mirrors.cloud.tencent.com/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/rimraf/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://mirrors.cloud.tencent.com/npm/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/rimraf/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://mirrors.cloud.tencent.com/npm/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/roarr": { "version": "2.15.4", "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", diff --git a/src/common/data.ts b/src/common/data.ts index 1d14bdd..43d1835 100644 --- a/src/common/data.ts +++ b/src/common/data.ts @@ -35,14 +35,14 @@ export async function getFriend(qq: string, uid: string = ""): Promise friend[filterKey] === filterValue.toString()) - if (!friend) { - try { - friends = (await NTQQApi.getFriends(true)) - friend = friends.find(friend => friend[filterKey] === filterValue.toString()) - } catch (e) { - // log("刷新好友列表失败", e.stack.toString()) - } - } + // if (!friend) { + // try { + // friends = (await NTQQApi.getFriends(true)) + // friend = friends.find(friend => friend[filterKey] === filterValue.toString()) + // } catch (e) { + // // log("刷新好友列表失败", e.stack.toString()) + // } + // } return friend } diff --git a/src/common/db.ts b/src/common/db.ts index dd5d7df..16af692 100644 --- a/src/common/db.ts +++ b/src/common/db.ts @@ -3,6 +3,7 @@ import {Level} from "level"; import {RawMessage} from "../ntqqapi/types"; import {DATA_DIR, log} from "./utils"; import {selfInfo} from "./data"; +import * as wasi from "wasi"; class DBUtil { @@ -54,7 +55,7 @@ class DBUtil { const longIdKey = this.DB_KEY_PREFIX_MSG_ID + msg.msgId const shortIdKey = this.DB_KEY_PREFIX_MSG_SHORT_ID + msg.msgShortId const seqIdKey = this.DB_KEY_PREFIX_MSG_SEQ_ID + msg.msgSeq - this.cache[longIdKey] = this.cache[shortIdKey] = this.cache[seqIdKey] = msg + this.cache[longIdKey] = this.cache[shortIdKey] = msg } async getMsgByShortId(shortMsgId: number): Promise { @@ -92,6 +93,7 @@ class DBUtil { async addMsg(msg: RawMessage) { // 有则更新,无则添加 + // log("addMsg", msg.msgId, msg.msgSeq, msg.msgShortId); const longIdKey = this.DB_KEY_PREFIX_MSG_ID + msg.msgId let existMsg = this.cache[longIdKey] if (!existMsg) { @@ -102,6 +104,7 @@ class DBUtil { } } if (existMsg) { + // log("消息已存在", existMsg.msgSeq, existMsg.msgShortId, existMsg.msgId) this.updateMsg(msg).then() return existMsg.msgShortId } @@ -113,12 +116,21 @@ class DBUtil { try { this.db.put(shortIdKey, msg.msgId).then(); this.db.put(longIdKey, JSON.stringify(msg)).then(); - this.db.put(seqIdKey, msg.msgId).then(); - log(`消息入库 ${seqIdKey}: ${msg.msgId}, ${shortMsgId}: ${msg.msgId}`); + try { + if (!(await this.db.get(seqIdKey))) { + this.db.put(seqIdKey, msg.msgId).then(); + } + } catch (e) { + + } + this.cache[shortIdKey] = this.cache[longIdKey] = msg; + if (!this.cache[seqIdKey]) { + this.cache[seqIdKey] = msg; + } + // log(`消息入库 ${seqIdKey}: ${msg.msgId}, ${shortMsgId}: ${msg.msgId}`); } catch (e) { - log("addMsg db error", e.stack.toString()); + // log("addMsg db error", e.stack.toString()); } - this.cache[seqIdKey] = this.cache[shortIdKey] = this.cache[longIdKey] = msg; return shortMsgId } @@ -137,13 +149,24 @@ class DBUtil { this.db.put(longIdKey, JSON.stringify(existMsg)).then(); const shortIdKey = this.DB_KEY_PREFIX_MSG_SHORT_ID + existMsg.msgShortId; const seqIdKey = this.DB_KEY_PREFIX_MSG_SEQ_ID + msg.msgSeq; + if (!this.cache[seqIdKey]) { + this.cache[seqIdKey] = existMsg; + } this.db.put(shortIdKey, msg.msgId).then(); - this.db.put(seqIdKey, msg.msgId).then(); + try { + if (!(await this.db.get(seqIdKey))) { + this.db.put(seqIdKey, msg.msgId).then(); + } + } catch (e) { + + } + // log("更新消息", existMsg.msgSeq, existMsg.msgShortId, existMsg.msgId); } + private async genMsgShortId(): Promise { const key = "msg_current_short_id"; - if (this.currentShortId === undefined){ + if (this.currentShortId === undefined) { try { let id: string = await this.db.get(key); this.currentShortId = parseInt(id); diff --git a/src/main/main.ts b/src/main/main.ts index df6deed..2834942 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -155,7 +155,7 @@ function onLoad() { async function postReceiveMsg(msgList: RawMessage[]) { const {debug, reportSelfMessage} = getConfigUtil().getConfig(); for (let message of msgList) { - // log("收到新消息", message) + // log("收到新消息", message.msgSeq) message.msgShortId = await dbUtil.addMsg(message) OB11Constructor.message(message).then((msg) => { @@ -213,7 +213,7 @@ function onLoad() { // 不让入库覆盖原来消息,不然就获取不到撤回的消息内容了 continue } - dbUtil.addMsg(message).then(); + dbUtil.updateMsg(message).then(); } }) registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmd.SELF_SEND_MSG, async (payload) => { diff --git a/src/ntqqapi/hook.ts b/src/ntqqapi/hook.ts index dac68ac..821cf11 100644 --- a/src/ntqqapi/hook.ts +++ b/src/ntqqapi/hook.ts @@ -233,7 +233,7 @@ registerReceiveHook<{ registerReceiveHook<{ msgList: RawMessage[] }>(ReceiveCmd.NEW_MSG, (payload) => { const {autoDeleteFile, autoDeleteFileSecond} = getConfigUtil().getConfig() for (const message of payload.msgList) { - // log("收到新消息,push到历史记录", message) + // log("收到新消息,push到历史记录", message.msgSeq) dbUtil.addMsg(message).then() // 清理文件 if (!autoDeleteFile) { @@ -268,6 +268,8 @@ registerReceiveHook<{ msgRecord: RawMessage }>(ReceiveCmd.SELF_SEND_MSG, ({msgRe const message = msgRecord const peerUid = message.peerUid // log("收到自己发送成功的消息", Object.keys(sendMessagePool), message); + // log("收到自己发送成功的消息", message.msgSeq); + dbUtil.addMsg(message).then() const sendCallback = sendMessagePool[peerUid] if (sendCallback) { try { diff --git a/src/ntqqapi/ntcall.ts b/src/ntqqapi/ntcall.ts index 6d4727a..16c6f1d 100644 --- a/src/ntqqapi/ntcall.ts +++ b/src/ntqqapi/ntcall.ts @@ -422,7 +422,7 @@ export class NTQQApi { }) } - static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = false, timeout = 10000) { + static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) { const peerUid = peer.peerUid // 等待上一个相同的peer发送完 diff --git a/src/onebot11/action/BaseAction.ts b/src/onebot11/action/BaseAction.ts index 1f6116a..5d31019 100644 --- a/src/onebot11/action/BaseAction.ts +++ b/src/onebot11/action/BaseAction.ts @@ -21,7 +21,7 @@ class BaseAction { const resData = await this._handle(payload); return OB11Response.ok(resData); } catch (e) { - log("发送错误", e.stack) + log("发生错误", e.stack) return OB11Response.error(e.toString(), 200); } } diff --git a/src/onebot11/action/SendGroupMsg.ts b/src/onebot11/action/SendGroupMsg.ts index 0e483c9..9f6e274 100644 --- a/src/onebot11/action/SendGroupMsg.ts +++ b/src/onebot11/action/SendGroupMsg.ts @@ -1,9 +1,17 @@ import SendMsg from "./SendMsg"; -import {ActionName} from "./types"; +import {ActionName, BaseCheckResult} from "./types"; +import {OB11PostSendMsg} from "../types"; +import {log} from "../../common/utils"; class SendGroupMsg extends SendMsg { actionName = ActionName.SendGroupMsg + + protected async check(payload: OB11PostSendMsg): Promise { + delete payload.user_id; + payload.message_type = "group" + return super.check(payload); + } } export default SendGroupMsg \ No newline at end of file diff --git a/src/onebot11/action/SendLike.ts b/src/onebot11/action/SendLike.ts index a0c6123..c26f412 100644 --- a/src/onebot11/action/SendLike.ts +++ b/src/onebot11/action/SendLike.ts @@ -1,5 +1,5 @@ import BaseAction from "./BaseAction"; -import {getFriend} from "../../common/data"; +import {getFriend, getUidByUin, uidMaps} from "../../common/data"; import {NTQQApi} from "../../ntqqapi/ntcall"; import {ActionName} from "./types"; @@ -14,11 +14,15 @@ export default class SendLike extends BaseAction { protected async _handle(payload: Payload): Promise { const qq = payload.user_id.toString(); const friend = await getFriend(qq) + let uid: string; if (!friend) { - throw (`点赞失败,${qq}不是好友`) + uid = getUidByUin(qq) + } + else{ + uid = friend.uid } try { - let result = await NTQQApi.likeFriend(friend.uid, parseInt(payload.times.toString()) || 1); + let result = await NTQQApi.likeFriend(uid, parseInt(payload.times?.toString()) || 1); if (result.result !== 0) { throw result.errMsg } diff --git a/src/onebot11/action/SendMsg.ts b/src/onebot11/action/SendMsg.ts index d26622d..f3eea71 100644 --- a/src/onebot11/action/SendMsg.ts +++ b/src/onebot11/action/SendMsg.ts @@ -157,7 +157,7 @@ export class SendMsg extends BaseAction { // log("send msg:", peer, sendElements) const {sendElements, deleteAfterSentFiles} = await this.createSendElements(messages, group) try { - const returnMsg = await this.send(peer, sendElements, deleteAfterSentFiles, isTempMsg) + const returnMsg = await this.send(peer, sendElements, deleteAfterSentFiles) return {message_id: returnMsg.msgShortId} } catch (e) { log("发送消息失败", e.stack.toString()) diff --git a/src/onebot11/action/SendPrivateMsg.ts b/src/onebot11/action/SendPrivateMsg.ts index 5ce5b95..8e2e26d 100644 --- a/src/onebot11/action/SendPrivateMsg.ts +++ b/src/onebot11/action/SendPrivateMsg.ts @@ -1,8 +1,14 @@ import SendMsg from "./SendMsg"; -import {ActionName} from "./types"; +import {ActionName, BaseCheckResult} from "./types"; +import {OB11PostSendMsg} from "../types"; class SendPrivateMsg extends SendMsg { actionName = ActionName.SendPrivateMsg + + protected async check(payload: OB11PostSendMsg): Promise { + payload.message_type = "private" + return super.check(payload); + } } export default SendPrivateMsg \ No newline at end of file diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index 6cfa350..4d7a210 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -96,9 +96,10 @@ export class OB11Constructor { message_data["data"]["text"] = text } else if (element.replyElement) { message_data["type"] = "reply" - log("收到回复消息", element.replyElement.replayMsgSeq) + // log("收到回复消息", element.replyElement.replayMsgSeq) try{ const replyMsg = await dbUtil.getMsgBySeqId(element.replyElement.replayMsgSeq) + // log("找到回复消息", replyMsg.msgShortId, replyMsg.msgId) if (replyMsg) { message_data["data"]["id"] = replyMsg.msgShortId.toString() } else { @@ -123,7 +124,7 @@ export class OB11Constructor { url: IMAGE_HTTP_HOST + element.picElement.originImageUrl, downloadFunc: async () => { await NTQQApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid, - element.elementId, element.picElement.thumbPath.get(0), element.picElement.sourcePath) + element.elementId, element.picElement.thumbPath?.get(0) || "", element.picElement.sourcePath) } }) // 不在自动下载图片 diff --git a/src/version.ts b/src/version.ts index 57c7fab..32ac7a8 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = "3.13.3" \ No newline at end of file +export const version = "3.13.4" \ No newline at end of file