Skip to content

Commit dc74dd4

Browse files
committed
feat: new filter rule
1 parent 161f2a2 commit dc74dd4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/modules/say.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,21 @@ for (const [botName, config] of Object.entries(configs)) {
8989
if (message.reply_markup?.inline_keyboard) {
9090
matchCount += 2;
9191
}
92+
if (message.entities) {
93+
matchCount += message.entities.filter(e => e.type === 'url').length;
94+
}
9295
if (message.caption_entities) {
93-
matchCount += message.caption_entities.filter(e => e.type === 'text_link').length / 2;
96+
matchCount += message.caption_entities.filter(e => e.type === 'text_link').length;
9497
}
98+
const isAdmin = config.adminChatIds?.includes(currentChat.id)
9599
// 有按钮就认为是垃圾消息(让管理员可见以方便测试)
96100
if (matchCount >= 2) {
97-
await sendMessageToCurrentChat(`\`filtered by firewall(${matchCount})\``, {
101+
await sendMessageToCurrentChat(`\`filtered by firewall(${isAdmin ? 'weight=' + matchCount : (new Date().getMilliseconds() + 10) % 30})\``, {
98102
parse_mode: 'MarkdownV2'
99103
})
100104
return
101105
}
102-
if (config.adminChatIds?.includes(currentChat.id) && isPrivate) return
106+
if (isAdmin && isPrivate) return
103107
const shortcut = config.list.find((el) => el.id === currentChatId)?.name
104108

105109
for (const el of config.adminChatIds || []) {

0 commit comments

Comments
 (0)