新增小红书、XMPP、元宝、Zalo 四个渠道扩展。 小红书渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, media, status, window XMPP 渠道扩展主要模块:plugin, config, gateway, outbound, streaming, pairing, security, dedupe, accounts, commands, muc, rate_limiter, stanza_utils, status, monitor 元宝渠道扩展主要模块:plugin, client, config_schema, gateway, outbound(chunk/queue/transport), inbound(dispatcher), streaming, pairing, security, accounts, actions, commands, codec(biz/conn), session, shared, utils Zalo 渠道扩展主要模块:api, config, gateway, webhook, outbound, pairing, security, session, polling, monitor, status
25 lines
743 B
Python
25 lines
743 B
Python
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
|
|
def clean_for_xiaohongshu(text: str) -> str:
|
|
text = re.sub(r"```\w*\n?", "", text)
|
|
text = re.sub(r"`([^`]+)`", r"\1", text)
|
|
text = re.sub(r"\*\*([^*]+)\*\*", r"\1", text)
|
|
text = re.sub(r"\*([^*]+)\*", r"\1", text)
|
|
text = re.sub(r"__([^_]+)__", r"\1", text)
|
|
text = re.sub(r"_([^_]+)_", r"\1", text)
|
|
text = re.sub(r"(?m)^#{1,6}\s+", "", text)
|
|
text = re.sub(r"(?m)^[-*_]{3,}\s*$", "", text)
|
|
text = re.sub(r"https?://\S+", "[链接]", text)
|
|
return text.strip()
|
|
|
|
|
|
def sanitize_text(text: str, payload: object | None = None) -> str:
|
|
return clean_for_xiaohongshu(text)
|
|
|
|
|
|
def markdown_to_native(md_text: str) -> str:
|
|
return clean_for_xiaohongshu(md_text)
|