feat: 基于正则规则引擎的新闻分类 + 发帖自动高亮 - #5
Open
jiubook wants to merge 8 commits into
Open
Conversation
## 分类优化 (classify_rules.json) - 将硬编码关键词匹配重构为 JSON 规则引擎,支持正则表达式 - 按优先级顺序匹配,首个命中的规则生效 - 支持排除模式(如 captions/subtitle 排除 bedrock_release) - 修复 'Closed captions for Bedrock Edition' 误判为基岩版资讯的问题 - 新增 host(主机资讯)和 flash(快讯)分类类型 ## 发帖自动高亮 (poster.py) - 发帖成功后自动根据新闻类型设置 MCBBS 帖子高亮 - 版本资讯(正式版)→ 红色 #EE1B2E - 版本资讯(快照/预发布/RC/测试版)→ 绿色 #3C9D40 - 快讯 → 粉色 #EC1282 - 主机资讯 → 橙色 #EE5023 - 周边消息 → 蓝色 #2B65B7 - 高亮失败不影响发帖结果
- 将 modcp.php 改为 forum.php?mod=topicadmin&action=moderate (正确的 Discuz 管理端点) - 先 GET 获取高亮表单,再 POST 提交 - 优雅处理无权限情况(打印错误信息,不影响发帖) - 支持从表单动态提取 formhash 和 action URL
- moderate[] 传递 thread ID - operations[] 传递操作类型 - 补充 highlight_style、expirationhighlight 等必需字段 - 已在 MCBBS thread-5394 上实测成功
- HIGHLIGHT_COLOR_MAP 新增 'normal': 3(默认蓝色) - poster.py: news_type 为 None 时默认为 'normal' 确保所有帖子都有高亮 - utils.py classify_article_type 逻辑不变,由调用方决定兜底行为
- classify_rules.json: 关键词'快讯'改为'块讯' - HIGHLIGHT_COLOR_MAP: 'normal' 兜底从蓝色(3)改为粉色(8) - 快讯和块讯统一为粉色(8)
- 快照: 匹配 'minecraft 26 2 snapshot 8' 和 '25w08a' 两种格式 - 预发布/候选: 支持连字符和空格分隔 - 基岩版: 匹配 'Bedrock Edition 26 20 Changelog' 等新格式 - Java正式版: 支持 'Java Edition 26 2' 双向匹配 - 主机: 支持 'nintendo-switch' 连字符格式
- post_news_file: 检测到'需要审核'时跳过高亮,保存到 .pending_highlights.json - 新增 _save_pending_highlight: 保存待高亮信息(URL、类型、颜色) - 新增 process_pending_highlights: 处理待高亮帖子,成功则移除,失败则保留 - main.py: run_post/run_post_only 启动时先处理待高亮帖子
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更概述
1. 分类优化 (
classify_rules.json+utils.py)classify_article_type中的硬编码关键词匹配重构为 JSON 规则引擎,支持正则表达式caption/subtitle排除 bedrock_release)Closed captions for Bedrock Edition不再误判为基岩版资讯host(主机资讯)和flash(快讯)分类类型2. 发帖自动高亮 (
poster.py)发帖成功后自动根据新闻类型设置 MCBBS 帖子高亮:
高亮失败不影响发帖结果。
3. 配置更新 (
config.json)sortid_map新增host和flash类型映射测试
关键分类测试用例