Skip to content

Commit

Permalink
3.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
idanran committed Jan 28, 2024
1 parent 89e3ed3 commit 39823e0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 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": "3.9.0",
"version": "3.9.1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
8 changes: 4 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ const share = {

const sourceConst: Schema<SourceConst> = Schema.object({
type: Schema.const('source').required(),
name: Schema.string().required(),
name: Schema.string(),
...share,
blockingWords: Schema.array(String).role('table'),
blockingWords: Schema.array(String).role('table').default([]),
selfId: Schema.string().default('*')
})

Expand All @@ -76,10 +76,10 @@ const targetConst: Schema<TargetConst> = Schema.object({

const fullConst: Schema<FullConst> = Schema.object({
type: Schema.const('full').required(),
name: Schema.string().required(),
name: Schema.string(),
selfId: Schema.string().required(),
...share,
blockingWords: Schema.array(String).role('table'),
blockingWords: Schema.array(String).role('table').default([]),
simulateOriginal: Schema.boolean().default(false),
disabled: Schema.boolean().default(false),
} as const)
Expand Down
7 changes: 4 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ export function apply(ctx: Context, config: Config) {
const { event, sid } = session

for (const regexpStr of sConfig.blockingWords) {
const includeBlockingWord = event.message.elements.some(value => {
const hit = event.message.elements.some(value => {
if (value.type === 'text') {
return new RegExp(regexpStr).test(value.attrs.content)
}
return false
})

if (includeBlockingWord) return
if (hit) return
}

let rows: Pick<Sent, Keys<Sent>>[] = []
Expand Down Expand Up @@ -127,7 +127,8 @@ export function apply(ctx: Context, config: Config) {
avatar
})
} else {
prefix = h.text(`[${sConfig.name} - ${name}]\n`)
const altName = isNullable(sConfig.name) ? '' : `${sConfig.name} - `
prefix = h.text(`[${altName}${name}]\n`)
}
const payload: h[] = [prefix, ...filtered]

Expand Down
6 changes: 3 additions & 3 deletions src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- 仅用于「来源」
- 仅用于「目标」
- 用于「来源」或「目标」(通常用以双向转发)
- - name: 群组代称 (可随意填写)
- - name: 来源代称 (可随意填写)
blockingWords:
$description: 屏蔽词 (消息包含屏蔽词时不转发, 支持正则表达式)
$value: 正则表达式 (无需斜杠包围)
Expand All @@ -24,10 +24,10 @@
channelId: 频道 ID (可能与群组 ID 相同)
guildId: 群组 ID
simulateOriginal: 模拟原始作者 (仅在 discord 平台生效)
- name: 群组代称 (可随意填写, 仅在「来源」生效)
- name: 来源代称 (可随意填写)
selfId: 自身 ID
blockingWords:
$description: 屏蔽词 (消息包含屏蔽词时不转发, 支持正则表达式, 仅在「来源」生效)
$description: 屏蔽词 (消息包含屏蔽词时不转发, 支持正则表达式)
disabled: 是否禁用 (仅在「目标」生效)
platform: 平台名
channelId: 频道 ID (可能与群组 ID 相同)
Expand Down
5 changes: 4 additions & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ export class MessageParse {
}
return h('text', { content })
}
break
}
case 'record': {
if (this.recordEnable) {
return h('text', { content: '[语音]' })
}
break
}
case 'at': {
if (this.atEnable) {
const name = attrs.name ? attrs.name : attrs.id
const name = attrs.name || attrs.id
return h('text', { content: `@${name}` })
}
break
}
}
return value
Expand Down

0 comments on commit 39823e0

Please sign in to comment.