落地空运群内协同与锁舱出站。
群里按 BOT 通道激活当前工单、航线报价和成交跟进;没有 TMS 报价编号时用工单字段补齐仍调锁舱,避免被本地规则拦住。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -41,6 +41,47 @@ def _create_time(msgtime: Any) -> int:
|
||||
return n
|
||||
|
||||
|
||||
def _unwrap_text(raw: Any) -> str:
|
||||
"""
|
||||
从字符串或嵌套对象取出正文。
|
||||
|
||||
管家 content 经常是摘要;企微官方结构是 text.content。空、null 不当正文。
|
||||
"""
|
||||
if raw is None:
|
||||
return ""
|
||||
if isinstance(raw, str):
|
||||
text = raw.strip()
|
||||
if not text or text.lower() in {"null", "none"}:
|
||||
return ""
|
||||
if text.startswith("{") or text.startswith("["):
|
||||
try:
|
||||
return _unwrap_text(json.loads(text))
|
||||
except json.JSONDecodeError:
|
||||
return text
|
||||
return text
|
||||
if isinstance(raw, Mapping):
|
||||
for key in ("content", "text", "msg"):
|
||||
got = _unwrap_text(raw.get(key))
|
||||
if got:
|
||||
return got
|
||||
return ""
|
||||
return str(raw).strip()
|
||||
|
||||
|
||||
def _best_text(record: Mapping[str, Any], payload: Mapping[str, Any]) -> str:
|
||||
"""多处正文里取最长的一份,避免摘要盖掉带金额的原文。"""
|
||||
candidates = [
|
||||
_unwrap_text(record.get("content")),
|
||||
_unwrap_text(payload.get("content")),
|
||||
_unwrap_text(payload.get("text")),
|
||||
_unwrap_text(payload.get("msg")),
|
||||
]
|
||||
texts = [x for x in candidates if x]
|
||||
if not texts:
|
||||
return ""
|
||||
return max(texts, key=len)
|
||||
|
||||
|
||||
def _filename(msg_type: str, content: str, payload: Mapping[str, Any]) -> str:
|
||||
for key in ("filename", "file_name", "FileName", "title", "name"):
|
||||
val = str(payload.get(key) or "").strip()
|
||||
@@ -75,7 +116,7 @@ def archive_record_to_inbound(
|
||||
return None
|
||||
|
||||
payload = _as_mapping(record.get("msg_content") or record.get("msgcontent"))
|
||||
content = str(record.get("content") or payload.get("content") or "").strip()
|
||||
content = _best_text(record, payload)
|
||||
msgid = str(record.get("msgid") or record.get("msg_id") or "").strip()
|
||||
seq = record.get("seq")
|
||||
if not msgid:
|
||||
|
||||
Reference in New Issue
Block a user