'text', 'data' => ['text' => $text]] : new MessageSegment('text', ['text' => $text]); } // 处理 CatCode $content = mb_substr($end, 4); $cq = explode(',', $content); $object_type = array_shift($cq); $object_params = []; foreach ($cq as $v) { $key = mb_strstr($v, '=', true); $object_params[$key] = CatCode::decode(mb_substr(mb_strstr($v, '='), 1), true); } $arr[] = $assoc_result ? ['type' => $object_type, 'data' => $object_params] : new MessageSegment($object_type, $object_params); $msg = mb_substr(mb_strstr($rear, ']'), 1); } if (($trim_msg = trim($msg)) !== '' || ($msg !== '' && !$ignore_space)) { $text = CatCode::decode($trim_text ? $trim_msg : $msg); $arr[] = $assoc_result ? ['type' => 'text', 'data' => ['text' => $text]] : new MessageSegment('text', ['text' => $text]); } return $arr; } public static function convertToArr(MessageSegment|\Stringable|array|string $message) { if (is_array($message)) { return $message; } if ($message instanceof MessageSegment) { return [$message]; } if ($message instanceof \Stringable) { return new MessageSegment('text', ['text' => $message->__toString()]); } return new MessageSegment('text', ['text' => $message]); } }