From c6db6d986e7efe2a59c15b864991aae26dab5007 Mon Sep 17 00:00:00 2001 From: idranme <96647698+idranme@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:02:14 +0800 Subject: [PATCH] 4.2.1 --- package.json | 2 +- src/core.ts | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a9d4ab6..ee7abdf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@myrtus/koishi-plugin-forward", "description": "Forward messages", - "version": "4.2.0", + "version": "4.2.1", "main": "lib/index.js", "typings": "lib/index.d.ts", "files": [ diff --git a/src/core.ts b/src/core.ts index 697062f..af7e0b8 100644 --- a/src/core.ts +++ b/src/core.ts @@ -18,7 +18,7 @@ interface Sent { id?: number } -function transform(source: h[]): h[] { +function transform(source: h[], rules?: h.SyncVisitor): h[] { return h.transform(source, { at(attrs) { const name = attrs.name || attrs.id @@ -30,7 +30,8 @@ function transform(source: h[]): h[] { }, audio(attrs) { return h.text('[语音]') - } + }, + ...rules }) } @@ -93,6 +94,9 @@ export function apply(ctx: Context, config: Config) { to_sid: sid, to_channel_id: event.channel.id }) + if (sConfig.onlyQuote && rows.length === 0) { + return + } } else if (sConfig.onlyQuote) { return } else { @@ -108,7 +112,15 @@ export function apply(ctx: Context, config: Config) { return } - const filtered = transform(event.message.elements) + const filtered = transform(event.message.elements, { + at(attrs) { + if (sConfig.onlyQuote && attrs.id === event.selfId) { + return h.text('') + } + const name = attrs.name || attrs.id + return h.text(`@${name}`) + } + }) const sent: Sent[] = [] for (let index = 0; index < targetConfigs.length; index++) {