From c1be5d9e0f8dc1762e3bd8c48a227580dd80018d Mon Sep 17 00:00:00 2001 From: wood Date: Thu, 5 Sep 2024 15:20:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(link=5Ffilter):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=BF=87=E6=BB=A4=E5=99=A8=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=A0=87=E5=87=86=E5=8C=96=E5=87=BD=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=85=B3=E9=94=AE=E8=AF=8D=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/guard.py | 2 +- src/link_filter.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/guard.py b/src/guard.py index d9f58c2..d56fbd9 100644 --- a/src/guard.py +++ b/src/guard.py @@ -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: diff --git a/src/link_filter.py b/src/link_filter.py index 7ceeff9..0ddb84e 100644 --- a/src/link_filter.py +++ b/src/link_filter.py @@ -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':