From 68c5f4f0a8e6fa165159bb4a81cc5f8162b37e07 Mon Sep 17 00:00:00 2001 From: Liu Date: Fri, 21 Feb 2025 19:30:40 +0800 Subject: [PATCH] =?UTF-8?q?fixbug:=E8=A7=A3=E5=86=B3=E6=8A=A2=E7=AD=94?= =?UTF-8?q?=E5=92=8C=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game_task/game_task_encyclopedia.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/game_task/game_task_encyclopedia.py b/game_task/game_task_encyclopedia.py index e9e6a30..9791d15 100644 --- a/game_task/game_task_encyclopedia.py +++ b/game_task/game_task_encyclopedia.py @@ -198,17 +198,17 @@ def submit_answer(group_id, player_id, task_id, answer): player_name = player_row['player_name'] - # 检查任务ID格式并提取数字部分 - if not task_id.startswith("task_") or not task_id[5:].isdigit(): + # 检查任务ID是否为纯数字 + if not task_id.isdigit(): return ( f"😅 哎呀,小调皮\n" f"🌟 任务ID格式不对哦\n" - f"🎈 应该是 task_[数字]\n" - f"🌈 比如:task_1\n" + f"🎈 应该是纯数字\n" + f"🌈 比如:1\n" f"🎀 再试一次吧!" ) - active_task_id = int(task_id.split('_')[1]) + active_task_id = int(task_id) # 检查任务是否存在并获取任务详情 cursor.execute( @@ -219,14 +219,14 @@ def submit_answer(group_id, player_id, task_id, answer): if not task_data: return ( f"😔 哎呀,小伙伴\n" - f"🌼 群 {group_id} 的任务 {task_id} 不见了\n" + f"🌼 群 {group_id} 的任务 task_{active_task_id} 不见了\n" f"🎀 可能已经被抢答啦!" ) if task_data['status'] == 'completed': return ( f"😄 哈哈,太慢啦!\n" - f"🌟 任务 {task_id} 已完成\n" + f"🌟 任务 task_{active_task_id} 已完成\n" f"🎈 群 {group_id} 等你抢新任务哦!" ) @@ -296,8 +296,8 @@ def submit_answer(group_id, player_id, task_id, answer): return ( f"😅 哎呀,小调皮\n" f"🌟 任务ID格式不对哦\n" - f"🎈 应该是 task_[数字]\n" - f"🌈 比如:task_1\n" + f"🎈 应该是纯数字\n" + f"🌈 比如:1\n" f"🎀 再试一次吧!" ) finally: @@ -417,7 +417,7 @@ def game_process_message(group_id, player_id, message, player_name="未知玩家 f"😅 哎呀,小朋友\n" f"🌟 格式不对哦\n" f"🎈 正确用法:/answer [任务ID] [答案]\n" - f"🌈 例如:/answer task_1 钒(Vanadium)" + f"🌈 例如:/answer 1 钒(Vanadium)" ) task_id, answer = parts[1], parts[2] return submit_answer(group_id, player_id, task_id, answer)