diff --git a/danding_bot/plugins/chatai/screenshot.py b/danding_bot/plugins/chatai/screenshot.py index 2e965f6..b4b8d33 100644 --- a/danding_bot/plugins/chatai/screenshot.py +++ b/danding_bot/plugins/chatai/screenshot.py @@ -2,7 +2,11 @@ import asyncio import re import html as html_module import markdown -import bleach +try: + import bleach + _HAS_BLEACH = True +except ImportError: + _HAS_BLEACH = False from nonebot import logger async def markdown_to_image(markdown_text: str, output_path: str, browser=None): @@ -21,7 +25,10 @@ async def markdown_to_image(markdown_text: str, output_path: str, browser=None): 'strong', 'em', 'b', 'i', 'u', 'a', 'img', 'div', ] allowed_attrs = {'a': ['href', 'title'], 'img': ['src', 'alt', 'title']} - html_content = bleach.clean(html_content, tags=allowed_tags, attributes=allowed_attrs) + if _HAS_BLEACH: + html_content = bleach.clean(html_content, tags=allowed_tags, attributes=allowed_attrs) + else: + logger.warning("[chatai] bleach 未安装,跳过 HTML 净化(请运行 pip install bleach)") # 使用传入的浏览器实例或创建新的 if browser is None: diff --git a/danding_bot/plugins/damo_balance/__init__.py b/danding_bot/plugins/damo_balance/__init__.py index a395079..a254a04 100644 --- a/danding_bot/plugins/damo_balance/__init__.py +++ b/danding_bot/plugins/damo_balance/__init__.py @@ -69,7 +69,7 @@ async def handle_captcha(event: MessageEvent, state: T_State, captcha: str = Arg spider = state.get("spider") if not spider: - await check_balance.finish("会话异常,请重新发送"大漠余额"") + await check_balance.finish('会话异常,请重新发送"大漠余额"') try: if spider.login(USERNAME, PASSWORD, captcha): diff --git a/requirements.txt b/requirements.txt index 51ce5cb..1b1fe79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,8 @@ arclet-alconna==1.8.35 arclet-alconna-tools==0.7.10 argcomplete==3.5.2 async-timeout==5.0.1 +openai>=1.0.0 +pyppeteer>=1.0.2 beautifulsoup4==4.12.3 bleach==6.2.0 bs4==0.0.2