适配MW 1.43

master
落雨楓 4 days ago
parent 533a905c40
commit 0b899e24c3

@ -2,8 +2,8 @@
"name": "hyperzlib/isekai-ai-review", "name": "hyperzlib/isekai-ai-review",
"type": "mediawiki-extension", "type": "mediawiki-extension",
"require": { "require": {
"alibabacloud/sdk": "^1.8", "paquettg/php-html-parser": "^2.2",
"paquettg/php-html-parser": "^2.2" "alibabacloud/green": "^1.8"
}, },
"authors": [ "authors": [
{ {

@ -21,13 +21,8 @@
"i18n" "i18n"
] ]
}, },
"AutoloadClasses": { "AutoloadNamespaces": {
"Isekai\\AIReview\\Hooks": "includes/Hooks.php", "Isekai\\AIReview\\": "includes/"
"Isekai\\AIReview\\SectionSplitter": "includes/SectionSplitter.php",
"Isekai\\AIReview\\Utils": "includes/Utils.php",
"Isekai\\AIReview\\AliyunAIReview": "includes/AliyunAIReview.php",
"Isekai\\AIReview\\AIReviewJob": "includes/AIReviewJob.php",
"Isekai\\AIReview\\LogFormatter": "includes/LogFormatter.php"
}, },
"Hooks": { "Hooks": {
"ModerationPending": [ "ModerationPending": [
@ -47,11 +42,21 @@
"aireview": "moderation" "aireview": "moderation"
}, },
"config": { "config": {
"AIReviewEndpoint": "cn-shanghai", "AIReviewEndpoint": {
"AIReviewAccessKeyId": "", "value": "cn-shanghai"
"AIReviewAccessKeySecret": "", },
"AIReviewBizType": null, "AIReviewAccessKeyId": {
"AIReviewRobotUID": 1 "value": ""
}, },
"manifest_version": 1 "AIReviewAccessKeySecret": {
} "value": ""
},
"AIReviewBizType": {
"value": null
},
"AIReviewRobotUID": {
"value": 1
}
},
"manifest_version": 2
}

@ -16,9 +16,9 @@ class AIReviewJob extends Job {
* 运行job开始进行AI审核 * 运行job开始进行AI审核
*/ */
public function run(){ public function run(){
global $wgAIReviewRobotUID;
$services = MediaWikiServices::getInstance(); $services = MediaWikiServices::getInstance();
$config = $services->getMainConfig();
$wgAIReviewRobotUID = $config->get('AIReviewRobotUID');
$dbr = $services->getDBLoadBalancer()->getMaintenanceConnectionRef(DB_REPLICA); $dbr = $services->getDBLoadBalancer()->getMaintenanceConnectionRef(DB_REPLICA);
@ -61,9 +61,9 @@ class AIReviewJob extends Job {
'isekai-aireview', 'isekai-aireview',
'Approve revision on: ' . $title->getText() 'Approve revision on: ' . $title->getText()
); );
Utils::addAIReviewLog('approve', $robotUser, $modUser, $title, $mod_id);
$approveEntry = $entryFactory->findApprovableEntry($mod_id); $approveEntry = $entryFactory->findApprovableEntry($mod_id);
$approveEntry->approve($robotUser); $approveEntry->approve($robotUser);
Utils::addAIReviewLog('approve', $robotUser, $modUser, $title, $mod_id);
$services->getHookContainer()->run("IsekaiAIReviewResult", $services->getHookContainer()->run("IsekaiAIReviewResult",
[ true, $title, $mod_id, $modUser, '' ]); [ true, $title, $mod_id, $modUser, '' ]);
return true; return true;

@ -9,6 +9,7 @@ class Hooks {
//加入审核队列 //加入审核队列
$title = Title::newFromText($fields['mod_title']); $title = Title::newFromText($fields['mod_title']);
$job = new AIReviewJob($title, ['mod_id' => $mod_id]); $job = new AIReviewJob($title, ['mod_id' => $mod_id]);
MediaWikiServices::getInstance()->getJobQueueGroup()->push($job); $jobQueue = MediaWikiServices::getInstance()->getJobQueueGroup();
$jobQueue->push($job);
} }
} }

@ -0,0 +1,54 @@
<?php
namespace Isekai\AIReview\Maintenance;
use Isekai\AIReview\AliyunAIReview;
use MediaWiki\MediaWikiServices;
use Maintenance;
/**
* Make sure the index for the wiki is sane.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*/
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
}
require_once "$IP/maintenance/Maintenance.php";
class TryAIReview extends Maintenance {
public function __construct() {
parent::__construct();
$this->addDescription('Test AI Review');
}
public function execute() {
$services = MediaWikiServices::getInstance();
$entryFactory = $services->getService('Moderation.EntryFactory');
$robotUser = $services->getUserFactory()->newFromId(1);
$approveEntry = $entryFactory->findApprovableEntry(1228);
$approveEntry->approve($robotUser);
return true;
}
}
$maintClass = TryAIReview::class;
require_once RUN_MAINTENANCE_IF_MAIN;

@ -0,0 +1 @@
测试AI审核
Loading…
Cancel
Save