From 1ac717b67f223486bf8c2288f6caaa57b8852633 Mon Sep 17 00:00:00 2001 From: PKC278 <52959804+PKC278@users.noreply.github.com> Date: Fri, 2 Jan 2026 17:11:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(message):=20=E4=BF=AE=E5=A4=8D=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BB=A5=E9=81=BF=E5=85=8D=E7=A9=BA=E5=80=BC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/message.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/chain/message.py b/app/chain/message.py index 25469417..275224bd 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -195,10 +195,14 @@ class MessageChain(ChainBase): if text.isdigit(): # 用户选择了具体的条目 # 缓存 - cache_data: dict = user_cache.get(userid).copy() + cache_data: dict = user_cache.get(userid) + if not cache_data: + # 发送消息 + self.post_message(Notification(channel=channel, source=source, title="输入有误!", userid=userid)) + return + cache_data = cache_data.copy() # 选择项目 - if not cache_data \ - or not cache_data.get('items') \ + if not cache_data.get('items') \ or len(cache_data.get('items')) < int(text): # 发送消息 self.post_message(Notification(channel=channel, source=source, title="输入有误!", userid=userid)) @@ -370,12 +374,13 @@ class MessageChain(ChainBase): del cache_data elif text.lower() == "p": # 上一页 - cache_data: dict = user_cache.get(userid).copy() + cache_data: dict = user_cache.get(userid) if not cache_data: # 没有缓存 self.post_message(Notification( channel=channel, source=source, title="输入有误!", userid=userid)) return + cache_data = cache_data.copy() try: if _current_page == 0: # 第一页 @@ -422,12 +427,13 @@ class MessageChain(ChainBase): del cache_data elif text.lower() == "n": # 下一页 - cache_data: dict = user_cache.get(userid).copy() + cache_data: dict = user_cache.get(userid) if not cache_data: # 没有缓存 self.post_message(Notification( channel=channel, source=source, title="输入有误!", userid=userid)) return + cache_data = cache_data.copy() try: cache_type: str = cache_data.get('type') # 产生副本,避免修改原值