import subprocess import time from pathlib import Path import psutil from playwright.async_api import async_playwright import os import asyncio import re from loguru import logger try: import markdown except ImportError: markdown = None META_KEYWORDS = ["群", "群名", "时间", "日期", "成员", "消息", "统计", "总结", "来源", "生成", "记录"] def _simple_markdown_to_html(md_content: str) -> str: lines = str(md_content or "").splitlines() html_parts = [] in_ul = False paragraph_lines = [] def flush_paragraph(): nonlocal paragraph_lines if paragraph_lines: text = " ".join(item.strip() for item in paragraph_lines if item.strip()) if text: html_parts.append(f"

{text}

") paragraph_lines = [] def close_ul(): nonlocal in_ul if in_ul: html_parts.append("") in_ul = False for raw_line in lines: line = raw_line.rstrip() stripped = line.strip() if not stripped: flush_paragraph() close_ul() continue if stripped.startswith("# "): flush_paragraph() close_ul() html_parts.append(f"

{stripped[2:].strip()}

") continue if stripped.startswith("## "): flush_paragraph() close_ul() html_parts.append(f"

{stripped[3:].strip()}

") continue if stripped.startswith("### "): flush_paragraph() close_ul() html_parts.append(f"

{stripped[4:].strip()}

") continue if stripped.startswith("- "): flush_paragraph() if not in_ul: html_parts.append("