调价后的新价格写入报价单;多段段前的货物带到各段,协同群不再把体积里的星号吃掉。海运字段齐了先核对再查价。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
@@ -18,6 +19,26 @@ from agent.config import get_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 含星号的尺寸或箱量,如 1.1*2.1*2.1、40HQ*1。已在行内代码里的不再套。
|
||||
_CODE_OR_STAR = re.compile(r"`[^`]*`|([A-Za-z0-9.]+(?:\s*\*\s*[A-Za-z0-9.]+)+)")
|
||||
|
||||
|
||||
def protect_markdown_asterisks(text: str) -> str:
|
||||
"""
|
||||
协同群正文走企微 markdown。星号会被当成强调,1.1*2.1*2.1 会显示成 1.12.12.1。
|
||||
|
||||
把含星号的一段放进行内代码,群里看到的仍是星号,不会变成灰底以外的别的字。
|
||||
已经套过代码的不再套第二层。不改账上的体积原文,只改这一次出站文字。
|
||||
"""
|
||||
|
||||
def _wrap(match: re.Match[str]) -> str:
|
||||
token = match.group(1)
|
||||
if not token:
|
||||
return match.group(0)
|
||||
return f"`{token}`"
|
||||
|
||||
return _CODE_OR_STAR.sub(_wrap, text or "")
|
||||
|
||||
|
||||
class AibotReplyClient:
|
||||
"""
|
||||
@@ -41,7 +62,7 @@ class AibotReplyClient:
|
||||
mention_userids: list[str] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
_ = mention_userids
|
||||
text = str(content or "").strip()
|
||||
text = protect_markdown_asterisks(str(content or "").strip())
|
||||
self.sent.append({"chat_id": chat_id, "content": text, "kind": "text"})
|
||||
if not text:
|
||||
return {"ok": False, "error": "empty"}
|
||||
|
||||
Reference in New Issue
Block a user