From 03ce925ec41fb3aa8fc9680fd1297cbc51cd237b Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Thu, 22 Jan 2026 13:25:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AI=20=E5=9E=83=E5=9C=BE=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=A3=80=E6=B5=8B=E6=94=AF=E6=8C=81=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E7=A0=81=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为每个检测过的评论生成唯一的 8 位识别码 - 识别码由数字和大写字母组成(排除 I、O) - 扩展 ai-summary-query.php 支持查询垃圾评论检测记录 - 显示评论信息、检测结果、AI 模型等详细信息 - 批量检测时也为所有评论生成识别码 - 所有 AI 相关内容均可通过识别码在 /ai-query 页面查询 --- ai-summary-query.php | 179 +++++++++++++++++++++++++++++++++++++++++-- functions.php | 43 ++++++++++- 2 files changed, 216 insertions(+), 6 deletions(-) diff --git a/ai-summary-query.php b/ai-summary-query.php index cb1461d..3b853e1 100644 --- a/ai-summary-query.php +++ b/ai-summary-query.php @@ -1,6 +1,6 @@ get_var($wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_argon_ai_summary_code' AND meta_value = %s", @@ -160,7 +162,9 @@ if (!empty($query_code)) { if ($post_id) { $post = get_post($post_id); if ($post && $post->post_status === 'publish') { + $query_type = 'summary'; $result = [ + 'type' => 'summary', 'post_id' => $post_id, 'post_title' => get_the_title($post_id), 'post_url' => get_permalink($post_id), @@ -194,7 +198,65 @@ if (!empty($query_code)) { $error = __('文章不存在或未发布', 'argon'); } } else { - $error = __('未找到对应的 AI 生成内容记录', 'argon'); + // 查询垃圾评论检测记录 + $comment_id = $wpdb->get_var($wpdb->prepare( + "SELECT comment_id FROM {$wpdb->commentmeta} + WHERE meta_key = '_argon_spam_detection_code' AND meta_value = %s", + $query_code + )); + + if ($comment_id) { + $comment = get_comment($comment_id); + if ($comment) { + $query_type = 'spam_detection'; + $detection_result = get_comment_meta($comment_id, '_argon_spam_detection_result', true); + $detection_time = get_comment_meta($comment_id, '_argon_spam_detection_time', true); + + $result = [ + 'type' => 'spam_detection', + 'comment_id' => $comment_id, + 'comment_author' => $comment->comment_author, + 'comment_email' => $comment->comment_author_email, + 'comment_content' => $comment->comment_content, + 'comment_date' => $comment->comment_date, + 'comment_status' => wp_get_comment_status($comment_id), + 'post_id' => $comment->comment_post_ID, + 'post_title' => get_the_title($comment->comment_post_ID), + 'post_url' => get_permalink($comment->comment_post_ID), + 'comment_url' => get_comment_link($comment), + 'is_spam' => isset($detection_result['is_spam']) ? $detection_result['is_spam'] : false, + 'reason' => isset($detection_result['reason']) ? $detection_result['reason'] : '', + 'action' => isset($detection_result['action']) ? $detection_result['action'] : '', + 'detection_time' => $detection_time, + 'code' => $query_code + ]; + + // 获取 AI 配置信息 + $result['provider'] = get_option('argon_ai_summary_provider', 'openai'); + $result['model'] = get_option('argon_ai_summary_model', ''); + + $provider_names = [ + 'openai' => 'OpenAI', + 'anthropic' => 'Anthropic', + 'deepseek' => 'DeepSeek', + 'qianwen' => '通义千问', + 'wenxin' => '文心一言', + 'doubao' => '豆包', + 'kimi' => 'Kimi', + 'zhipu' => '智谱', + 'siliconflow' => 'SiliconFlow' + ]; + + $result['provider_display'] = isset($provider_names[$result['provider']]) ? $provider_names[$result['provider']] : $result['provider']; + + // 缓存结果(1小时) + set_transient($cache_key, $result, 3600); + } else { + $error = __('评论不存在', 'argon'); + } + } else { + $error = __('未找到对应的 AI 生成内容记录', 'argon'); + } } } } @@ -368,7 +430,7 @@ html.darkmode .ai-verify-subtitle { color: #aaa; } - +
@@ -426,11 +488,118 @@ html.darkmode .ai-verify-subtitle { color: #aaa; } + + + +