Hide SIM label in WeCom; count completed rounds from closed groups.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,11 +55,11 @@ def wecom_webhook_url() -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def venue_label() -> str:
|
||||
"""模拟盘 / 实盘·OKX / 实盘·BINANCE。"""
|
||||
def venue_label() -> str | None:
|
||||
"""实盘时返回「实盘·交易所」;SIM 不展示盘口标签。"""
|
||||
s = get_settings()
|
||||
if s.is_sim:
|
||||
return "模拟盘"
|
||||
return None
|
||||
try:
|
||||
ex = load_runtime_settings().exchange
|
||||
except Exception:
|
||||
@@ -67,13 +67,17 @@ def venue_label() -> str:
|
||||
ex_u = str(ex).strip().lower()
|
||||
if ex_u in ("binance", "bn"):
|
||||
return "实盘·币安"
|
||||
if ex_u in ("gate", "gateio"):
|
||||
return "实盘·Gate"
|
||||
return "实盘·OKX"
|
||||
|
||||
|
||||
def build_markdown(*, tag: str, title: str, lines: list[str] | None = None) -> str:
|
||||
body = "\n".join(f"> {ln}" if not ln.startswith(">") else ln for ln in (lines or []))
|
||||
venue = venue_label()
|
||||
head = f"## 【{venue}】{title}" if venue else f"## {title}"
|
||||
parts = [
|
||||
f"## 【{venue_label()}】{title}",
|
||||
head,
|
||||
f"> **标识**: `{tag}`",
|
||||
f"> **时间**: {time.strftime('%Y-%m-%d %H:%M:%S')}",
|
||||
]
|
||||
@@ -211,9 +215,13 @@ def notify_fault(*, title: str, detail: str, dedupe_key: str | None = None) -> N
|
||||
|
||||
|
||||
def notify_test() -> tuple[bool, str]:
|
||||
venue = venue_label()
|
||||
lines = ["企业微信通知已连通。"]
|
||||
if venue:
|
||||
lines.append(f"当前盘口标签: **{venue}**")
|
||||
content = build_markdown(
|
||||
tag=TAG_TEST,
|
||||
title="测试推送",
|
||||
lines=["企业微信通知已连通。", f"当前盘口标签: **{venue_label()}**"],
|
||||
lines=lines,
|
||||
)
|
||||
return _post_markdown_sync(content)
|
||||
|
||||
Reference in New Issue
Block a user