feat: 移除未使用的消息处理函数和Markdown插件任务创建功能,优化代码结构
This commit is contained in:
@@ -3245,55 +3245,6 @@ class DialogController extends AbstractController
|
||||
return Base::retSuccess('success', $topMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/applied 标记消息已应用
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName msg__applied
|
||||
*
|
||||
* @apiParam {Number} index 索引
|
||||
* @apiParam {Number} msg_id 消息ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function msg__applied()
|
||||
{
|
||||
User::auth();
|
||||
//
|
||||
$msg_id = intval(Request::input('msg_id'));
|
||||
$index = intval(Request::input('index'));
|
||||
//
|
||||
$msg = WebSocketDialogMsg::whereId($msg_id)->first();
|
||||
if (empty($msg)) {
|
||||
return Base::retError("消息不存在或已被删除");
|
||||
}
|
||||
WebSocketDialog::checkDialog($msg->dialog_id);
|
||||
//
|
||||
$originalMsg = $msg->getRawOriginal('msg');
|
||||
$pattern = '/:::\s*(create-task-list|create-subtask-list)(?:\s+(\S+))?/';
|
||||
$count = -1;
|
||||
$updatedMsg = preg_replace_callback($pattern, function($matches) use (&$count, $index) {
|
||||
$count++;
|
||||
if ($count === $index || ($index === 0 && $count === 1)) {
|
||||
return "::: {$matches[1]} applied";
|
||||
}
|
||||
return $matches[0];
|
||||
}, $originalMsg);
|
||||
|
||||
if ($count === -1) {
|
||||
return Base::retError("未找到可应用的规则");
|
||||
}
|
||||
|
||||
$msg->msg = $updatedMsg;
|
||||
$msg->save();
|
||||
//
|
||||
return Base::retSuccess("success");
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/sticker/search 搜索在线表情
|
||||
*
|
||||
|
||||
@@ -695,7 +695,6 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
$text = $title;
|
||||
} else {
|
||||
$text = Base::markdown2html($text);
|
||||
$text = self::previewConvertTaskList($text);
|
||||
}
|
||||
}
|
||||
$text = preg_replace("/<img\s+class=\"emoticon\"[^>]*?alt=\"(\S+)\"[^>]*?>/", "[$1]", $text);
|
||||
@@ -711,36 +710,6 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换任务列表
|
||||
* @param $text
|
||||
* @return array|string|string[]|null
|
||||
*/
|
||||
private static function previewConvertTaskList($text) {
|
||||
$pattern = '/:::\s*(create-task-list|create-subtask-list)(.*?):::/s';
|
||||
$replacement = function($matches) {
|
||||
$content = $matches[2];
|
||||
$lines = explode("\n", trim($content));
|
||||
$result = [];
|
||||
$currentTitle = '';
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if (empty($line)) continue;
|
||||
|
||||
if (preg_match('/^title:\s*(.+)$/', $line, $titleMatch)) {
|
||||
$currentTitle = $titleMatch[1];
|
||||
$result[] = $currentTitle;
|
||||
} elseif (preg_match('/^desc:\s*(.+)$/', $line, $descMatch)) {
|
||||
if (!empty($currentTitle)) {
|
||||
$result[] = $descMatch[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode("\n", $result);
|
||||
};
|
||||
return preg_replace_callback($pattern, $replacement, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览文件消息
|
||||
* @param $msg
|
||||
|
||||
Reference in New Issue
Block a user