From d215bb158756ebe5265b725b4922624eea2c8596 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 27 Feb 2025 20:24:02 +0800 Subject: [PATCH 1/2] Update utils.py --- HackathonBot/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HackathonBot/utils.py b/HackathonBot/utils.py index 85774fb..f2ba975 100644 --- a/HackathonBot/utils.py +++ b/HackathonBot/utils.py @@ -98,9 +98,9 @@ def process_issue(task_text, config): """ task_list = [] for i in range(config['max_task_id']): - start = task_text.find('| {} |'.format(i + 1)) + exists = re.search(r'\|\s*{}\s*\|'.format(i+1), task_text) # 如果没有找到该编号的任务,直接返回 - if start < 0: + if not exists: logger.error('没有从issue内容中找到编号为【{}】的赛题,请检查issue内容格式是否正确'.format(str(i + 1))) task_list.append(None) continue @@ -492,4 +492,4 @@ def update_statistic_info(task_list, config): for user_name in users_info: statistic_info += "@{} ({}) ".format(user_name, str(users_info[user_name])) statistic_info += "\n" - return statistic_info \ No newline at end of file + return statistic_info From a9c4f2824b0ff91088885c2d390529de1daaf6ad Mon Sep 17 00:00:00 2001 From: DrRyanHuang Date: Fri, 28 Feb 2025 02:51:49 +0000 Subject: [PATCH 2/2] str.find -> re.search --- HackathonBot/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HackathonBot/utils.py b/HackathonBot/utils.py index f2ba975..f0a97d9 100644 --- a/HackathonBot/utils.py +++ b/HackathonBot/utils.py @@ -100,10 +100,11 @@ def process_issue(task_text, config): for i in range(config['max_task_id']): exists = re.search(r'\|\s*{}\s*\|'.format(i+1), task_text) # 如果没有找到该编号的任务,直接返回 - if not exists: + if exists is None: logger.error('没有从issue内容中找到编号为【{}】的赛题,请检查issue内容格式是否正确'.format(str(i + 1))) task_list.append(None) continue + start = exists.span()[0] end = start + 1 column = 0 task = {}