适配MW 1.43

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

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

@ -21,13 +21,8 @@
"i18n"
]
},
"AutoloadClasses": {
"Isekai\\AIReview\\Hooks": "includes/Hooks.php",
"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"
"AutoloadNamespaces": {
"Isekai\\AIReview\\": "includes/"
},
"Hooks": {
"ModerationPending": [
@ -47,11 +42,21 @@
"aireview": "moderation"
},
"config": {
"AIReviewEndpoint": "cn-shanghai",
"AIReviewAccessKeyId": "",
"AIReviewAccessKeySecret": "",
"AIReviewBizType": null,
"AIReviewRobotUID": 1
},
"manifest_version": 1
}
"AIReviewEndpoint": {
"value": "cn-shanghai"
},
"AIReviewAccessKeyId": {
"value": ""
},
"AIReviewAccessKeySecret": {
"value": ""
},
"AIReviewBizType": {
"value": null
},
"AIReviewRobotUID": {
"value": 1
}
},
"manifest_version": 2
}

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

@ -9,6 +9,7 @@ class Hooks {
//加入审核队列
$title = Title::newFromText($fields['mod_title']);
$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