Commit e04c804

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-09-06 19:12:49
feat(social): add unsupported link warning
1 parent 4522238
Changed files (1)
src/handler.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+import asyncio
 import re
 
 from loguru import logger
@@ -16,7 +17,7 @@ from llm.gpt import gpt_response
 from llm.summary import ai_summary
 from messages.parser import parse_msg
 from messages.sender import send2tg
-from messages.utils import equal_prefix, startswith_prefix
+from messages.utils import delete_message, equal_prefix, startswith_prefix
 from networking import match_social_media_link
 from others.convert_chinese import chinese_conversion
 from others.download_external import download_url_in_message
@@ -287,8 +288,14 @@ async def handle_social_media(
                 sent_messages = await preview_ytdlp(client, message, proxy=PROXY.YTDLP_FALLBACK, **kwargs)
         if warn_msg:
             await warn_msg.delete()
-        # if ytdlp failed, download directly
-        if (
+
+        if any(keyword in info["text"] for keyword in ["facebook.com", "threads.com"]):
+            if kwargs.get("show_progress"):
+                warn_msg = await message.reply_text("⚠️该链接不被支持", quote=True)
+                await asyncio.sleep(10)
+                await delete_message(warn_msg)
+        # if ytdlp failed, try to download directly
+        elif (
             not sent_messages
             and startswith_prefix(this_texts, prefix=cmd_prefix)
             and matched["platform"]
@@ -311,6 +318,7 @@ async def handle_social_media(
             if kwargs.get("show_progress"):
                 kwargs["progress"] = await client.send_message(info["cid"], text="⚠️暂时不支持解析链接, 尝试直接下载该网页")
             await download_url_in_message(client, this_msg, extra_prefix=cmd_prefix, **kwargs)
+
     except Exception as e:
         logger.exception(e)