diff --git a/includes/AIReviewJob.php b/includes/AIReviewJob.php index a682aad..68ef85b 100644 --- a/includes/AIReviewJob.php +++ b/includes/AIReviewJob.php @@ -15,7 +15,7 @@ class AIReviewJob extends Job { /** * 运行job,开始进行AI审核 */ - public function run(){ + public function run() { $services = MediaWikiServices::getInstance(); $config = $services->getMainConfig(); $wgAIReviewRobotUID = $config->get('AIReviewRobotUID'); diff --git a/includes/AliyunAIReview.php b/includes/AliyunAIReview.php index ec598b9..cede881 100644 --- a/includes/AliyunAIReview.php +++ b/includes/AliyunAIReview.php @@ -7,7 +7,7 @@ use AlibabaCloud\Green\Green; class AliyunAIReview { private const MAX_LENGTH = 10000; - public function __construct(){ + public function __construct() { global $wgAIReviewEndpoint, $wgAIReviewAccessKeyId, $wgAIReviewAccessKeySecret; AlibabaCloud::accessKeyClient($wgAIReviewAccessKeyId, $wgAIReviewAccessKeySecret) ->connectTimeout(3) @@ -21,7 +21,7 @@ class AliyunAIReview { return $response; } - public function buildRequestData($text){ + public function buildRequestData($text) { global $wgAIReviewBizType; $reqData = [ @@ -33,7 +33,7 @@ class AliyunAIReview { return $reqData; } - public function buildTasks($text){ + public function buildTasks($text) { $splitter = new SectionSplitter($text, self::MAX_LENGTH); $chunkList = $splitter->getChunkList(); $taskList = []; @@ -67,7 +67,7 @@ class AliyunAIReview { } } - public function parseResponse($response){ + public function parseResponse($response) { if($response['code'] !== 200) return ['pass' => false, 'reason' => wfMessage('isekai-aireview-aliyun-server-error', $response['code'])->escaped()]; diff --git a/includes/Hooks.php b/includes/Hooks.php index 277059c..9257424 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -5,7 +5,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Title\Title; class Hooks { - public static function onModerationPending($fields, $mod_id){ + public static function onModerationPending($fields, $mod_id) { //加入审核队列 $title = Title::newFromText($fields['mod_title']); $job = new AIReviewJob($title, ['mod_id' => $mod_id]); diff --git a/includes/LogFormatter.php b/includes/LogFormatter.php index be86790..c2b3083 100644 --- a/includes/LogFormatter.php +++ b/includes/LogFormatter.php @@ -34,7 +34,7 @@ class LogFormatter extends GlobalLogFormatter { return $params; } - public function getMessageParameters(){ + public function getMessageParameters() { $params = parent::getMessageParameters(); $entryParams = $this->entry->getParameters(); $type = $this->entry->getSubtype(); diff --git a/includes/SectionSplitter.php b/includes/SectionSplitter.php index a79b53f..ac9b60b 100644 --- a/includes/SectionSplitter.php +++ b/includes/SectionSplitter.php @@ -7,7 +7,7 @@ class SectionSplitter { private $bufferLength = 0; private $maxLength; - public function __construct($text, $maxLength = 10000){ + public function __construct($text, $maxLength = 10000) { $this->maxLength = $maxLength; $this->splitLine($text); } @@ -28,7 +28,7 @@ class SectionSplitter { /** * 按照行来拆分 */ - public function splitLine($text){ + public function splitLine($text) { $text = str_replace("\r\n", "\n", $text); $lines = explode("\n", $text); foreach($lines as $line){ @@ -46,7 +46,7 @@ class SectionSplitter { /** * 按照句子来拆分 */ - public function splitSentence($text){ //我就不信一句话能一万字 + public function splitSentence($text) { //我就不信一句话能一万字 $sentences = explode("\0", preg_replace('/(。|\\.)/', "$1\0", $text)); foreach($sentences as $sentence){ if(mb_strlen($sentence, 'UTF-8') > $this->maxLength){ //一句话能说一万字吗? @@ -60,7 +60,7 @@ class SectionSplitter { /** * 强制拆分 */ - public function forceSplit($text){ + public function forceSplit($text) { $len = mb_strlen($text, 'UTF-8'); $times = ceil($len / $this->maxLength); for($i = 0; $i < $times; $i ++){ @@ -72,7 +72,7 @@ class SectionSplitter { } } - public function getChunkList(){ + public function getChunkList() { return $this->chunkList; } } \ No newline at end of file diff --git a/includes/Utils.php b/includes/Utils.php index a3cedaa..75d3b9d 100644 --- a/includes/Utils.php +++ b/includes/Utils.php @@ -27,7 +27,7 @@ class Utils { return trim(implode("\n", $lines)); } - public static function getReadableReason($reasons){ + public static function getReadableReason($reasons) { $allowedReasons = ['spam', 'ad', 'politics', 'terrorism', 'abuse', 'porn', 'flood', 'contraband', 'meaningless', 'customized', 'normal']; if(is_string($reasons)) return $reasons; @@ -47,7 +47,7 @@ class Utils { /** * @throws \MWException */ - public static function addAIReviewLog($event, $robotUser, $modUser, $title, $modid, $reason = null){ + public static function addAIReviewLog($event, $robotUser, $modUser, $title, $modid, $reason = null) { $entry = new ManualLogEntry('aireview', $event); $entry->setPerformer($robotUser); $entry->setTarget($title);