fix: 修复 damo_balance 引号语法错误及 chatai bleach 缺失依赖
- damo_balance/__init__.py: 将外层字符串改为单引号,消除内嵌双引号引起的 SyntaxError - chatai/screenshot.py: bleach 改为 try/except 可选导入,无 bleach 时降级跳过 HTML 净化 - requirements.txt: 补充 openai>=1.0.0 与 pyppeteer>=1.0.2 依赖声明
This commit is contained in:
@@ -2,7 +2,11 @@ import asyncio
|
|||||||
import re
|
import re
|
||||||
import html as html_module
|
import html as html_module
|
||||||
import markdown
|
import markdown
|
||||||
import bleach
|
try:
|
||||||
|
import bleach
|
||||||
|
_HAS_BLEACH = True
|
||||||
|
except ImportError:
|
||||||
|
_HAS_BLEACH = False
|
||||||
from nonebot import logger
|
from nonebot import logger
|
||||||
|
|
||||||
async def markdown_to_image(markdown_text: str, output_path: str, browser=None):
|
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',
|
'strong', 'em', 'b', 'i', 'u', 'a', 'img', 'div',
|
||||||
]
|
]
|
||||||
allowed_attrs = {'a': ['href', 'title'], 'img': ['src', 'alt', 'title']}
|
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:
|
if browser is None:
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ async def handle_captcha(event: MessageEvent, state: T_State, captcha: str = Arg
|
|||||||
|
|
||||||
spider = state.get("spider")
|
spider = state.get("spider")
|
||||||
if not spider:
|
if not spider:
|
||||||
await check_balance.finish("会话异常,请重新发送"大漠余额"")
|
await check_balance.finish('会话异常,请重新发送"大漠余额"')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if spider.login(USERNAME, PASSWORD, captcha):
|
if spider.login(USERNAME, PASSWORD, captcha):
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ arclet-alconna==1.8.35
|
|||||||
arclet-alconna-tools==0.7.10
|
arclet-alconna-tools==0.7.10
|
||||||
argcomplete==3.5.2
|
argcomplete==3.5.2
|
||||||
async-timeout==5.0.1
|
async-timeout==5.0.1
|
||||||
|
openai>=1.0.0
|
||||||
|
pyppeteer>=1.0.2
|
||||||
beautifulsoup4==4.12.3
|
beautifulsoup4==4.12.3
|
||||||
bleach==6.2.0
|
bleach==6.2.0
|
||||||
bs4==0.0.2
|
bs4==0.0.2
|
||||||
|
|||||||
Reference in New Issue
Block a user