从文件内容中提取期号 :param file_path: 周刊文件路径 :return: 期号字符串
(file_path)
| 439 | await bot.send_message(chat_id=chat_id, text=text, parse_mode='Markdown', disable_web_page_preview=True) |
| 440 | |
| 441 | def extract_weekly_no(file_path): |
| 442 | """ |
| 443 | 从文件内容中提取期号 |
| 444 | :param file_path: 周刊文件路径 |
| 445 | :return: 期号字符串 |
| 446 | """ |
| 447 | print(f"Extracting weekly number from {file_path}") |
| 448 | with open(file_path, 'r', encoding="utf-8") as f: |
| 449 | content = f.read() |
| 450 | # 用正则从 title 字段提取期号,不依赖行号 |
| 451 | match = re.search(r"title:\s*'[^']*?#(\d+)", content) |
| 452 | if match: |
| 453 | return match.group(1) |
| 454 | else: |
| 455 | raise ValueError("Invalid weekly no format: could not find issue number in title") |
| 456 | |
| 457 | def get_message(weekly_no, content_body): |
| 458 | """ |
no outgoing calls
no test coverage detected