feat: 富消息升级 — 催办用模板卡片 + 公告用 Markdown
scheduler.py: - 未填报经理 → 模板卡片消息(标题+描述+「去填报」按钮) - 支局长/领导 → Markdown 每日填报汇总(markdown) - 文本消息作为降级方案 wecom.py API: - remind: 模板卡片优先 → 降级文本 - announcement: Markdown 优先 → 降级文本 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -201,9 +201,17 @@ async def send_reminder(
|
||||
wecom_ids = [r[0] for r in result.all() if r[0]]
|
||||
|
||||
content = data.message or "📋 请及时完成今日拜访记录填报。"
|
||||
success = await wecom_client.send_text_message(wecom_ids, content)
|
||||
success = await wecom_client.send_template_card(
|
||||
user_ids=wecom_ids,
|
||||
title="📋 填报提醒",
|
||||
desc=content,
|
||||
url="https://qj.dhdx.fun/m",
|
||||
btn_text="去填报",
|
||||
)
|
||||
if not success:
|
||||
success = await wecom_client.send_text_message(wecom_ids, content)
|
||||
|
||||
return {"success": success, "sent_to": len(wecom_ids)}
|
||||
return {"success": success, "sent_to": len(wecom_ids), "rich": True}
|
||||
|
||||
|
||||
@router.post("/announcement")
|
||||
@@ -212,14 +220,16 @@ async def send_announcement(
|
||||
current_user: dict = Depends(require_director),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Director sends an announcement to all team members."""
|
||||
"""Director sends an announcement to all team members (markdown)."""
|
||||
result = await db.execute(select(User.wecom_userid).where(User.wecom_userid.isnot(None)))
|
||||
wecom_ids = [r[0] for r in result.all()]
|
||||
|
||||
content = f"📢 支局长公告\n\n{data.content}"
|
||||
success = await wecom_client.send_text_message(wecom_ids, content)
|
||||
markdown = f"## 📢 支局长公告\n\n{data.content}"
|
||||
success = await wecom_client.send_markdown_message(markdown)
|
||||
if not success:
|
||||
success = await wecom_client.send_text_message(wecom_ids, f"📢 支局长公告\n\n{data.content}")
|
||||
|
||||
return {"success": success, "sent_to": len(wecom_ids)}
|
||||
return {"success": success, "sent_to": len(wecom_ids), "rich": True}
|
||||
|
||||
|
||||
@router.post("/test-message")
|
||||
|
||||
Reference in New Issue
Block a user