Skip to content

Commit

Permalink
4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme committed Dec 23, 2024
1 parent 40dbfca commit c6db6d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
18 changes: 15 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Sent {
id?: number
}

function transform(source: h[]): h[] {
function transform(source: h[], rules?: h.SyncVisitor<never>): h[] {
return h.transform(source, {
at(attrs) {
const name = attrs.name || attrs.id
Expand All @@ -30,7 +30,8 @@ function transform(source: h[]): h[] {
},
audio(attrs) {
return h.text('[语音]')
}
},
...rules
})
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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++) {
Expand Down

0 comments on commit c6db6d9

Please sign in to comment.