mirror of
https://github.com/woodchen-ink/Q58Bot.git
synced 2025-07-18 05:42:06 +08:00
refactor(link_filter): 优化链接过滤器中的链接标准化函数,修复关键词处理逻辑
This commit is contained in:
parent
ac1bcbc105
commit
c1be5d9e0f
@ -67,7 +67,7 @@ async def process_message(event, client):
|
||||
logger.info(f"Message should be filtered: {event.message.text}")
|
||||
if event.sender_id != ADMIN_ID:
|
||||
await event.delete()
|
||||
notification = await event.respond("已撤回该消息。注:包含关键词或重复发送的非白名单链接会被自动撤回。")
|
||||
notification = await event.respond("已撤回该消息。注:已置顶项目分享链接, 二次分享链接, 都会被撤回.")
|
||||
asyncio.create_task(delete_message_after_delay(client, event.chat_id, notification, 3 * 60))
|
||||
return
|
||||
if new_links:
|
||||
|
@ -108,6 +108,7 @@ class LinkFilter:
|
||||
new_non_whitelisted_links = []
|
||||
for link in links:
|
||||
normalized_link = self.normalize_link(link)
|
||||
normalized_link = normalized_link.lstrip('/') # 去除开头的双斜杠
|
||||
if not self.is_whitelisted(normalized_link):
|
||||
logger.debug(f"Link not whitelisted: {normalized_link}")
|
||||
if normalized_link not in self.keywords:
|
||||
@ -120,6 +121,7 @@ class LinkFilter:
|
||||
if new_non_whitelisted_links:
|
||||
logger.info(f"New non-whitelisted links found: {new_non_whitelisted_links}")
|
||||
return False, new_non_whitelisted_links
|
||||
|
||||
|
||||
async def handle_keyword_command(self, event, command, args):
|
||||
if command == '/list':
|
||||
|
Loading…
x
Reference in New Issue
Block a user