From 01210172724f0ce8854759b52d64bda897cd7086 Mon Sep 17 00:00:00 2001 From: v6ole Date: Sun, 10 May 2026 14:29:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=80=E6=96=B0=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9E=E6=9C=80=E6=96=B05?= =?UTF-8?q?=E6=9D=A1=20+=20=E6=98=BE=E7=A4=BA=E6=9D=A5=E6=BA=90=E7=BD=91?= =?UTF-8?q?=E7=AB=99=20+=20=E8=8F=9C=E5=8D=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - latest_announcements 不再过滤 keyword_matched,返回全部最新5条 - 每条公告显示来源网站(广西政府采购网/大化县政府网采购公告) - 菜单「今日公告」改为顶级按钮「最新公告」,移除子菜单重复项 --- app/wechat/handler.py | 13 +++++++------ app/wechat/menu.py | 9 ++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/wechat/handler.py b/app/wechat/handler.py index 70df7f2..a436388 100644 --- a/app/wechat/handler.py +++ b/app/wechat/handler.py @@ -245,7 +245,6 @@ class WeChatMessageHandler: async for db in get_db(): stmt = ( select(Announcement) - .where(Announcement.keyword_matched == True) # noqa: E712 .order_by(desc(Announcement.publish_date)) .limit(5) ) @@ -253,14 +252,16 @@ class WeChatMessageHandler: items = result.scalars().all() if not items: - await self.client.send_text("暂无匹配关键词的公告", from_user) + await self.client.send_text("暂无公告", from_user) return None - lines = ["最新匹配公告(最近5条):"] + lines = ["最新公告(最近5条):"] for i, ann in enumerate(items, 1): - date_str = ann.publish_date.strftime("%m-%d") if ann.publish_date else "?" - title = ann.title[:30] + "..." if len(ann.title) > 30 else ann.title - lines.append(f"{i}. [{date_str}] {title}") + date_str = ann.publish_date.strftime("%m-%d %H:%M") if ann.publish_date else "?" + title = ann.title[:28] + "..." if len(ann.title) > 28 else ann.title + source = ann.source_name or ann.source_code + lines.append(f"{i}. [{date_str}] {source}") + lines.append(f" {title}") await self.client.send_text("\n".join(lines), from_user) except Exception as e: logger.error(f"查询最新公告失败: {e}") diff --git a/app/wechat/menu.py b/app/wechat/menu.py index 643b7ce..e2cb9d6 100644 --- a/app/wechat/menu.py +++ b/app/wechat/menu.py @@ -9,9 +9,9 @@ logger = logging.getLogger(__name__) MENU = { "button": [ { - "name": "今日公告", + "name": "最新公告", "type": "click", - "key": "today_stats", + "key": "latest_announcements", }, { "name": "查询", @@ -31,11 +31,6 @@ MENU = { "type": "click", "key": "workday_status", }, - { - "name": "最新公告", - "type": "click", - "key": "latest_announcements", - }, ], }, {