Merge commit 'a951a719d1518883474f36579b63bb8f9c4f0494' into pro

This commit is contained in:
kuaifan 2023-08-05 18:44:20 +08:00
commit b7d9ac7436
249 changed files with 1414 additions and 591 deletions

View File

@ -718,6 +718,7 @@ class DialogController extends AbstractController
} }
// //
$dialog_id = intval(Request::input('dialog_id')); $dialog_id = intval(Request::input('dialog_id'));
$dialog_ids = trim(Request::input('dialog_ids'));
$update_id = intval(Request::input('update_id')); $update_id = intval(Request::input('update_id'));
$update_mark = !($user->bot && in_array(strtolower(trim(Request::input('update_mark'))), ['no', 'false', '0'])); $update_mark = !($user->bot && in_array(strtolower(trim(Request::input('update_mark'))), ['no', 'false', '0']));
$reply_id = intval(Request::input('reply_id')); $reply_id = intval(Request::input('reply_id'));
@ -725,59 +726,65 @@ class DialogController extends AbstractController
$text_type = strtolower(trim(Request::input('text_type'))); $text_type = strtolower(trim(Request::input('text_type')));
$silence = in_array(strtolower(trim(Request::input('silence'))), ['yes', 'true', '1']); $silence = in_array(strtolower(trim(Request::input('silence'))), ['yes', 'true', '1']);
$markdown = in_array($text_type, ['md', 'markdown']); $markdown = in_array($text_type, ['md', 'markdown']);
// //
WebSocketDialog::checkDialog($dialog_id); $result = [];
// $dialogIds = $dialog_ids ? explode(',', $dialog_ids) : [$dialog_id ?: 0];
if ($update_id > 0) { foreach($dialogIds as $dialog_id) {
$action = $update_mark ? "update-$update_id" : "change-$update_id"; //
} elseif ($reply_id > 0) { WebSocketDialog::checkDialog($dialog_id);
$action = "reply-$reply_id"; //
} else { if ($update_id > 0) {
$action = ""; $action = $update_mark ? "update-$update_id" : "change-$update_id";
} } elseif ($reply_id > 0) {
// $action = "reply-$reply_id";
if (!$markdown) { } else {
$text = WebSocketDialogMsg::formatMsg($text, $dialog_id); $action = "";
}
$strlen = mb_strlen($text);
$noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
if ($strlen < 1) {
return Base::retError('消息内容不能为空');
}
if ($noimglen > 200000) {
return Base::retError('消息内容最大不能超过200000字');
}
if ($noimglen > 5000) {
// 内容过长转成文件发送
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
Base::makeDir(public_path($path));
$path = $path . md5($text) . ".htm";
$file = public_path($path);
file_put_contents($file, $text);
$size = filesize(public_path($path));
if (empty($size)) {
return Base::retError('消息发送保存失败');
} }
$ext = $markdown ? 'md' : 'htm'; //
$fileData = [ if (!$markdown) {
'name' => "LongText-{$strlen}.{$ext}", $text = WebSocketDialogMsg::formatMsg($text, $dialog_id);
'size' => $size, }
'file' => $file, $strlen = mb_strlen($text);
'path' => $path, $noimglen = mb_strlen(preg_replace("/<img[^>]*?>/i", "", $text));
'url' => Base::fillUrl($path), if ($strlen < 1) {
'thumb' => '', return Base::retError('消息内容不能为空');
'width' => -1, }
'height' => -1, if ($noimglen > 200000) {
'ext' => $ext, return Base::retError('消息内容最大不能超过200000字');
]; }
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid, false, false, $silence); if ($noimglen > 5000) {
// 内容过长转成文件发送
$path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
Base::makeDir(public_path($path));
$path = $path . md5($text) . ".htm";
$file = public_path($path);
file_put_contents($file, $text);
$size = filesize(public_path($path));
if (empty($size)) {
return Base::retError('消息发送保存失败');
}
$ext = $markdown ? 'md' : 'htm';
$fileData = [
'name' => "LongText-{$strlen}.{$ext}",
'size' => $size,
'file' => $file,
'path' => $path,
'url' => Base::fillUrl($path),
'thumb' => '',
'width' => -1,
'height' => -1,
'ext' => $ext,
];
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid, false, false, $silence);
}
//
$msgData = ['text' => $text];
if ($markdown) {
$msgData['type'] = 'md';
}
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence);
} }
// return $result;
$msgData = ['text' => $text];
if ($markdown) {
$msgData['type'] = 'md';
}
return WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence);
} }
/** /**

View File

@ -258,7 +258,9 @@ class SystemController extends AbstractController
'claude_agency', 'claude_agency',
'wenxin_key', 'wenxin_key',
'wenxin_secret', 'wenxin_secret',
'wenxin_model' 'wenxin_model',
'qianwen_key',
'qianwen_model'
]; ];
if ($type == 'save') { if ($type == 'save') {
@ -292,9 +294,16 @@ class SystemController extends AbstractController
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => "设置成功"], $botUser->userid, true, false, true); WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => "设置成功"], $botUser->userid, true, false, true);
} }
} }
if ($backup['qianwen_key'] != $setting['qianwen_key']) {
$botUser = User::botGetOrCreate('ai-qianwen');
if ($botUser && $dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid)) {
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => "设置成功"], $botUser->userid, true, false, true);
}
}
} }
// //
$setting['wenxin_model'] = $setting['wenxin_model'] ?: 'ERNIE-Bot-turbo'; $setting['wenxin_model'] = $setting['wenxin_model'] ?: 'ERNIE-Bot-turbo';
$setting['qianwen_model'] = $setting['qianwen_model'] ?: 'qwen-v1';
if (env("SYSTEM_SETTING") == 'disabled') { if (env("SYSTEM_SETTING") == 'disabled') {
foreach ($keys as $item) { foreach ($keys as $item) {
if (strlen($setting[$item]) > 12) { if (strlen($setting[$item]) > 12) {

View File

@ -1839,6 +1839,10 @@ class UsersController extends AbstractController
* @apiGroup users * @apiGroup users
* @apiName share__list * @apiName share__list
* *
* @apiParam {String} [type] 分享类型file-文件text-列表 默认file
* @apiParam {Number} [pid] 父级文件id用于获取子目录和上传到指定目录的id
* @apiParam {Number} [upload_file_id] 上传文件id
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误 * @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述) * @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据 * @apiSuccess {Object} data 返回数据
@ -1846,6 +1850,7 @@ class UsersController extends AbstractController
public function share__list() public function share__list()
{ {
$user = User::auth(); $user = User::auth();
$type = Request::input('type', 'file');
$pid = intval(Request::input('pid', -1)); $pid = intval(Request::input('pid', -1));
$uploadFileId = intval(Request::input('upload_file_id', -1)); $uploadFileId = intval(Request::input('upload_file_id', -1));
// 上传文件 // 上传文件
@ -1857,7 +1862,7 @@ class UsersController extends AbstractController
} }
// 获取数据 // 获取数据
$lists = []; $lists = [];
if ($pid !== -1) { if ($type == 'file' && $pid !== -1) {
$fileList = (new File)->getFileList($user, $pid, 'dir', false); $fileList = (new File)->getFileList($user, $pid, 'dir', false);
foreach ($fileList as $file) { foreach ($fileList as $file) {
if ($file['id'] != $pid) { if ($file['id'] != $pid) {
@ -1870,15 +1875,16 @@ class UsersController extends AbstractController
]; ];
} }
} }
} else { } else {
$lists[] = [ if($type == 'file'){
'type' => 'children', $lists[] = [
'url' => Base::fillUrl("api/users/share/list") . "?pid=0", 'type' => 'children',
'icon' => url("images/file/light/folder.png"), 'url' => Base::fillUrl("api/users/share/list") . "?pid=0",
'extend' => ['upload_file_id' => 0], 'icon' => url("images/file/light/folder.png"),
'name' => Doo::translate('文件'), 'extend' => ['upload_file_id' => 0],
]; 'name' => Doo::translate('文件'),
];
}
$dialogList = (new WebSocketDialog)->getDialogList($user->userid); $dialogList = (new WebSocketDialog)->getDialogList($user->userid);
foreach ($dialogList['data'] as $dialog) { foreach ($dialogList['data'] as $dialog) {
if ($dialog['avatar']) { if ($dialog['avatar']) {
@ -1897,8 +1903,13 @@ class UsersController extends AbstractController
'type' => 'item', 'type' => 'item',
'name' => $dialog['name'], 'name' => $dialog['name'],
'icon' => $avatar, 'icon' => $avatar,
'url' => Base::fillUrl("api/dialog/msg/sendfiles"), 'url' => $type == "file" ? Base::fillUrl("api/dialog/msg/sendfiles") : Base::fillUrl("api/dialog/msg/sendtext"),
'extend' => ['dialog_ids' => $dialog['id']] 'extend' => [
'dialog_ids' => $dialog['id'],
'text_type' => 'text',
'reply_id' => 0,
'silence' => 'no'
]
]; ];
} }
} }

View File

@ -55,7 +55,8 @@ class UserBot extends AbstractModel
'approval-alert' => '审批', 'approval-alert' => '审批',
'ai-openai' => 'ChatGPT', 'ai-openai' => 'ChatGPT',
'ai-claude' => 'Claude', 'ai-claude' => 'Claude',
'ai-wenxin' => 'Wenxin', 'ai-wenxin' => '文心一言',
'ai-qianwen' => '通义千问',
'bot-manager' => '机器人管理', 'bot-manager' => '机器人管理',
default => '', // 不是系统机器人时返回空(也可以拿来判断是否是系统机器人) default => '', // 不是系统机器人时返回空(也可以拿来判断是否是系统机器人)
}; };

View File

@ -641,7 +641,7 @@ class WebSocketDialogMsg extends AbstractModel
} }
// 其他网络图片 // 其他网络图片
$imageSaveLocal = Base::settingFind("system", "image_save_local"); $imageSaveLocal = Base::settingFind("system", "image_save_local");
preg_match_all("/<img[^>]*?src=([\"'])(.*?\.(png|jpg|jpeg|webp|gif))\\1[^>]*?>/is", $text, $matchs); preg_match_all("/<img[^>]*?src=([\"'])(.*?(png|jpg|jpeg|webp|gif).*?)\\1[^>]*?>/is", $text, $matchs);
foreach ($matchs[2] as $key => $str) { foreach ($matchs[2] as $key => $str) {
if ($imageSaveLocal === 'close') { if ($imageSaveLocal === 'close') {
$imageSize = getimagesize($str); $imageSize = getimagesize($str);

View File

@ -417,6 +417,22 @@ class BotReceiveMsgTask extends AbstractTask
$error = 'The client version is low (required version ≥ v0.29.12).'; $error = 'The client version is low (required version ≥ v0.29.12).';
} }
break; break;
// QianWen 机器人
case 'ai-qianwen@bot.system':
$setting = Base::setting('aibotSetting');
$webhookUrl = "{$serverUrl}/ai/qianwen/send";
$extras = [
'qianwen_key' => $setting['qianwen_key'],
'qianwen_model' => $setting['qianwen_model'],
'server_url' => $serverUrl,
];
if (empty($extras['qianwen_key'])) {
$error = 'Robot disabled.';
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
$error = 'The client version is low (required version ≥ v0.29.12).';
}
break;
// 其他机器人 // 其他机器人
default: default:
$userBot = UserBot::whereBotId($botUser->userid)->first(); $userBot = UserBot::whereBotId($botUser->userid)->first();

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Some files were not shown because too many files have changed in this diff Show More