mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
no message
This commit is contained in:
parent
f983146501
commit
3cd00e1343
@ -992,7 +992,7 @@ class ApproveController extends AbstractController
|
|||||||
'is_finished' => $process['is_finished'],
|
'is_finished' => $process['is_finished'],
|
||||||
'data' => $data
|
'data' => $data
|
||||||
];
|
];
|
||||||
$msgData['desc'] = match ($type) {
|
$msgData['title'] = match ($type) {
|
||||||
'approve_reviewer' => '待你审批',
|
'approve_reviewer' => '待你审批',
|
||||||
'approve_notifier' => '审批通知',
|
'approve_notifier' => '审批通知',
|
||||||
'approve_comment_notifier' => '审批评论通知',
|
'approve_comment_notifier' => '审批评论通知',
|
||||||
|
|||||||
@ -1092,7 +1092,7 @@ class FileController extends AbstractController
|
|||||||
//
|
//
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
'type' => 'file_download',
|
'type' => 'file_download',
|
||||||
'desc' => '文件下载打包已完成',
|
'title' => '文件下载打包已完成',
|
||||||
'name' => $fileName,
|
'name' => $fileName,
|
||||||
'size' => filesize($zipPath),
|
'size' => filesize($zipPath),
|
||||||
'url' => $fileUrl,
|
'url' => $fileUrl,
|
||||||
|
|||||||
@ -1688,12 +1688,11 @@ class ProjectTask extends AbstractModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dataId = $this->parent_id ?: $this->id;
|
$dataId = $this->parent_id ?: $this->id;
|
||||||
$taskHtml = "<span class=\"mention task\" data-id=\"{$dataId}\">#{$this->name}</span>";
|
|
||||||
$text = match ($type) {
|
$text = match ($type) {
|
||||||
1 => "您的任务 {$taskHtml} 即将超时。",
|
1 => "(*)即将超时",
|
||||||
2 => "您的任务 {$taskHtml} 已经超时。",
|
2 => "(*)已经超时",
|
||||||
3 => "您的任务 {$taskHtml} 时间已修改。",
|
3 => "(*)时间已修改",
|
||||||
default => "您有一个新任务 {$taskHtml}。",
|
default => "您有一个新任务",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
@ -1711,8 +1710,15 @@ class ProjectTask extends AbstractModel
|
|||||||
$dialog = WebSocketDialog::checkUserDialog($botUser, $receiver->userid);
|
$dialog = WebSocketDialog::checkUserDialog($botUser, $receiver->userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
ProjectTaskPushLog::createInstance($data)->save();
|
ProjectTaskPushLog::createInstance($data)->save();
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', [
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
'text' => str_replace("您的任务", $replace, $text) . $suffix
|
'type' => 'task_list',
|
||||||
|
'title' => str_replace("(*)", $replace, $text) . $suffix,
|
||||||
|
'list' => [
|
||||||
|
[
|
||||||
|
'id' => $dataId,
|
||||||
|
'name' => $this->name,
|
||||||
|
]
|
||||||
|
],
|
||||||
], in_array($type, [0, 3]) ? $userid : $botUser->userid);
|
], in_array($type, [0, 3]) ? $userid : $botUser->userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1720,11 +1726,12 @@ class ProjectTask extends AbstractModel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 移动任务
|
* 移动任务
|
||||||
* @param int $project_id
|
* @param int $projectId
|
||||||
* @param int $column_id
|
* @param int $columnId
|
||||||
* @param int $flowItemId
|
* @param int $flowItemId
|
||||||
* @param array $owner
|
* @param array $owner
|
||||||
* @param array $assist
|
* @param array $assist
|
||||||
|
* @param string $completeAt
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function moveTask(int $projectId, int $columnId,int $flowItemId = 0,array $owner = [], array $assist = [], string $completeAt='')
|
public function moveTask(int $projectId, int $columnId,int $flowItemId = 0,array $owner = [], array $assist = [], string $completeAt='')
|
||||||
|
|||||||
@ -250,11 +250,14 @@ class UserBot extends AbstractModel
|
|||||||
};
|
};
|
||||||
$sendMsg = function($type, $checkin) use ($alreadyTip, $getJokeSoup, $botUser, $nowDate) {
|
$sendMsg = function($type, $checkin) use ($alreadyTip, $getJokeSoup, $botUser, $nowDate) {
|
||||||
$cacheKey = "Checkin::sendMsg-{$nowDate}-{$type}:" . $checkin['userid'];
|
$cacheKey = "Checkin::sendMsg-{$nowDate}-{$type}:" . $checkin['userid'];
|
||||||
$typeDesc = $type == "up" ? "上班" : "下班";
|
$typeContent = $type == "up" ? "上班" : "下班";
|
||||||
if (Cache::get($cacheKey) === "yes") {
|
if (Cache::get($cacheKey) === "yes") {
|
||||||
if ($alreadyTip && $dialog = WebSocketDialog::checkUserDialog($botUser, $checkin['userid'])) {
|
if ($alreadyTip && $dialog = WebSocketDialog::checkUserDialog($botUser, $checkin['userid'])) {
|
||||||
$text = "<p>" . Doo::translate("今日已{$typeDesc}打卡,无需重复打卡。") . "</p>";
|
$text = "今日已{$typeContent}打卡,无需重复打卡。";
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, $type != "up");
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
|
'type' => 'content',
|
||||||
|
'content' => $text,
|
||||||
|
], $botUser->userid, false, false, $type != "up");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -263,12 +266,19 @@ class UserBot extends AbstractModel
|
|||||||
if ($dialog = WebSocketDialog::checkUserDialog($botUser, $checkin['userid'])) {
|
if ($dialog = WebSocketDialog::checkUserDialog($botUser, $checkin['userid'])) {
|
||||||
$hi = date("H:i");
|
$hi = date("H:i");
|
||||||
$remark = $checkin['remark'] ? " ({$checkin['remark']})": "";
|
$remark = $checkin['remark'] ? " ({$checkin['remark']})": "";
|
||||||
$text = "<p>{$typeDesc}" . Doo::translate("打卡成功,打卡时间") . ": {$hi}{$remark}</p>";
|
$subcontent = $getJokeSoup($type);
|
||||||
$suff = $getJokeSoup($type);
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
if ($suff) {
|
'type' => 'content',
|
||||||
$text = "{$text}<p>----------</p><p>{$suff}</p>";
|
'content' => [
|
||||||
}
|
[
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid, false, false, $type != "up");
|
'content' => "{$typeContent}打卡成功,打卡时间: {$hi}{$remark}"
|
||||||
|
], [
|
||||||
|
'content' => $subcontent,
|
||||||
|
'language' => false,
|
||||||
|
'style' => 'padding-top:4px;opacity:0.4',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
], $botUser->userid, false, false, $type != "up");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if ($timeAdvance <= Base::time() && Base::time() < $timeEnd) {
|
if ($timeAdvance <= Base::time() && Base::time() < $timeEnd) {
|
||||||
|
|||||||
@ -591,7 +591,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return $data['msg']['notice'];
|
return $data['msg']['notice'];
|
||||||
|
|
||||||
case 'template':
|
case 'template':
|
||||||
return Doo::translate($data['msg']['desc'] ?: '未知消息类型');
|
return $this->previewTemplateMsg($data['msg']);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$action = Doo::translate("未知的消息");
|
$action = Doo::translate("未知的消息");
|
||||||
@ -617,6 +617,26 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return "[{$action}] {$msg['name']}";
|
return "[{$action}] {$msg['name']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预览模板消息
|
||||||
|
* @param $msg
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function previewTemplateMsg($msg)
|
||||||
|
{
|
||||||
|
if (!empty($msg['title_raw'])) {
|
||||||
|
return $msg['title_raw'];
|
||||||
|
}
|
||||||
|
if (!empty($msg['title'])) {
|
||||||
|
return Doo::translate($msg['title']);
|
||||||
|
}
|
||||||
|
if ($msg['type'] === 'content' && is_string($msg['content']) && $msg['content'] !== '') {
|
||||||
|
return Doo::translate($msg['content']);
|
||||||
|
}
|
||||||
|
return Doo::translate('未知的消息');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成关键词
|
* 生成关键词
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@ -96,8 +96,8 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$text = UserBot::checkinBotQuickMsg($command, $msg->userid);
|
$text = UserBot::checkinBotQuickMsg($command, $msg->userid);
|
||||||
if ($text) {
|
if ($text) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
'type' => 'desc',
|
'type' => 'content',
|
||||||
'desc' => $text,
|
'content' => $text,
|
||||||
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,8 +106,8 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$text = UserBot::anonBotQuickMsg($command);
|
$text = UserBot::anonBotQuickMsg($command);
|
||||||
if ($text) {
|
if ($text) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
'type' => 'desc',
|
'type' => 'content',
|
||||||
'desc' => $text,
|
'content' => $text,
|
||||||
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,8 +120,8 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
} else {
|
} else {
|
||||||
$text = "非常抱歉,我不是你的机器人,无法完成你的指令。";
|
$text = "非常抱歉,我不是你的机器人,无法完成你的指令。";
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
'type' => 'desc',
|
'type' => 'content',
|
||||||
'desc' => $text,
|
'content' => $text,
|
||||||
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$array = Base::newTrim(explode(" ", "{$command} "));
|
$array = Base::newTrim(explode(" ", "{$command} "));
|
||||||
$type = $array[0];
|
$type = $array[0];
|
||||||
$data = [];
|
$data = [];
|
||||||
$desc = "";
|
$content = "";
|
||||||
if (!$isManager && in_array($type, ['/list', '/newbot'])) {
|
if (!$isManager && in_array($type, ['/list', '/newbot'])) {
|
||||||
return; // 这些操作仅支持【机器人管理】机器人
|
return; // 这些操作仅支持【机器人管理】机器人
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->get();
|
->get();
|
||||||
if ($data->isEmpty()) {
|
if ($data->isEmpty()) {
|
||||||
$desc = "您没有创建机器人。";
|
$content = "您没有创建机器人。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$botId = $isManager ? $array[1] : $botUser->userid;
|
$botId = $isManager ? $array[1] : $botUser->userid;
|
||||||
$data = $this->botManagerOne($botId, $msg->userid);
|
$data = $this->botManagerOne($botId, $msg->userid);
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -177,25 +177,25 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
->where('users.bot', 1)
|
->where('users.bot', 1)
|
||||||
->where('user_bots.userid', $msg->userid)
|
->where('user_bots.userid', $msg->userid)
|
||||||
->count() >= 50) {
|
->count() >= 50) {
|
||||||
$desc = "超过最大创建数量。";
|
$content = "超过最大创建数量。";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strlen($array[1]) < 2 || strlen($array[1]) > 20) {
|
if (strlen($array[1]) < 2 || strlen($array[1]) > 20) {
|
||||||
$desc = "机器人名称由2-20个字符组成。";
|
$content = "机器人名称由2-20个字符组成。";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$data = User::botGetOrCreate("user-" . Base::generatePassword(), [
|
$data = User::botGetOrCreate("user-" . Base::generatePassword(), [
|
||||||
'nickname' => $array[1]
|
'nickname' => $array[1]
|
||||||
], $msg->userid);
|
], $msg->userid);
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
$desc = "创建失败。";
|
$content = "创建失败。";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dialog = WebSocketDialog::checkUserDialog($data, $msg->userid);
|
$dialog = WebSocketDialog::checkUserDialog($data, $msg->userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
'type' => '/hello',
|
'type' => '/hello',
|
||||||
'desc' => '创建成功。',
|
'title' => '创建成功。',
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
], $data->userid); // todo 未能在任务end事件来发送任务
|
], $data->userid); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$botId = $isManager ? $array[1] : $botUser->userid;
|
$botId = $isManager ? $array[1] : $botUser->userid;
|
||||||
$nameString = $isManager ? $array[2] : $array[1];
|
$nameString = $isManager ? $array[2] : $array[1];
|
||||||
if (strlen($nameString) < 2 || strlen($nameString) > 20) {
|
if (strlen($nameString) < 2 || strlen($nameString) > 20) {
|
||||||
$desc = "机器人名称由2-20个字符组成。";
|
$content = "机器人名称由2-20个字符组成。";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$data = $this->botManagerOne($botId, $msg->userid);
|
$data = $this->botManagerOne($botId, $msg->userid);
|
||||||
@ -218,7 +218,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->pinyin = Base::cn2pinyin($nameString);
|
$data->pinyin = Base::cn2pinyin($nameString);
|
||||||
$data->save();
|
$data->save();
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
if ($data) {
|
if ($data) {
|
||||||
$data->deleteUser('delete bot');
|
$data->deleteUser('delete bot');
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
if ($data) {
|
if ($data) {
|
||||||
User::generateToken($data);
|
User::generateToken($data);
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->password = Doo::md5s(Base::generatePassword(32), $data->encrypt);
|
$data->password = Doo::md5s(Base::generatePassword(32), $data->encrypt);
|
||||||
$data->save();
|
$data->save();
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->clear_day = $userBot->clear_day;
|
$data->clear_day = $userBot->clear_day;
|
||||||
$data->clear_at = $userBot->clear_at; // 这两个参数只是作为输出,所以不保存
|
$data->clear_at = $userBot->clear_at; // 这两个参数只是作为输出,所以不保存
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$webhookUrl = $isManager ? $array[2] : $array[1];
|
$webhookUrl = $isManager ? $array[2] : $array[1];
|
||||||
$data = $this->botManagerOne($botId, $msg->userid);
|
$data = $this->botManagerOne($botId, $msg->userid);
|
||||||
if (strlen($webhookUrl) > 255) {
|
if (strlen($webhookUrl) > 255) {
|
||||||
$desc = "webhook地址最长仅支持255个字符。";
|
$content = "webhook地址最长仅支持255个字符。";
|
||||||
} elseif ($data) {
|
} elseif ($data) {
|
||||||
$userBot = UserBot::whereBotId($botId)->whereUserid($msg->userid)->first();
|
$userBot = UserBot::whereBotId($botId)->whereUserid($msg->userid)->first();
|
||||||
if ($userBot) {
|
if ($userBot) {
|
||||||
@ -304,7 +304,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->webhook_url = $userBot->webhook_url ?: '-';
|
$data->webhook_url = $userBot->webhook_url ?: '-';
|
||||||
$data->webhook_num = $userBot->webhook_num; // 这两个参数只是作为输出,所以不保存
|
$data->webhook_num = $userBot->webhook_num; // 这两个参数只是作为输出,所以不保存
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
->take(20)
|
->take(20)
|
||||||
->get();
|
->get();
|
||||||
if ($list->isEmpty()) {
|
if ($list->isEmpty()) {
|
||||||
$desc = "没有搜索到相关会话。";
|
$content = "没有搜索到相关会话。";
|
||||||
} else {
|
} else {
|
||||||
$list->transform(function (WebSocketDialog $item) use ($data) {
|
$list->transform(function (WebSocketDialog $item) use ($data) {
|
||||||
return $item->formatData($data->userid);
|
return $item->formatData($data->userid);
|
||||||
@ -333,23 +333,23 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->list = $list; // 这个参数只是作为输出,所以不保存
|
$data->list = $list; // 这个参数只是作为输出,所以不保存
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$desc = "机器人不存在。";
|
$content = "机器人不存在。";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
if ($desc) {
|
if ($content) {
|
||||||
$msgData = [
|
$msgData = [
|
||||||
'type' => 'desc',
|
'type' => 'content',
|
||||||
'desc' => $desc,
|
'content' => $content,
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$msgData = [
|
$msgData = [
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
];
|
];
|
||||||
$msgData['desc'] = match ($type) {
|
$msgData['title'] = match ($type) {
|
||||||
'/hello' => '您好',
|
'/hello' => '您好',
|
||||||
'/help' => '帮助指令',
|
'/help' => '帮助指令',
|
||||||
'/list' => '我的机器人',
|
'/list' => '我的机器人',
|
||||||
@ -388,7 +388,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$serverUrl = 'http://' . env('APP_IPPR') . '.3';
|
$serverUrl = 'http://' . env('APP_IPPR') . '.3';
|
||||||
$userBot = null;
|
$userBot = null;
|
||||||
$extras = [];
|
$extras = [];
|
||||||
$errorDesc = null;
|
$errorContent = null;
|
||||||
switch ($botUser->email) {
|
switch ($botUser->email) {
|
||||||
// ChatGPT 机器人
|
// ChatGPT 机器人
|
||||||
case 'ai-openai@bot.system':
|
case 'ai-openai@bot.system':
|
||||||
@ -402,10 +402,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'chunk_size' => 7,
|
'chunk_size' => 7,
|
||||||
];
|
];
|
||||||
if (empty($extras['openai_key'])) {
|
if (empty($extras['openai_key'])) {
|
||||||
$errorDesc = '机器人未启用。';
|
$errorContent = '机器人未启用。';
|
||||||
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
||||||
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
||||||
$errorDesc = '当前客户端版本低(所需版本≥v0.29.11)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.29.11)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Claude 机器人
|
// Claude 机器人
|
||||||
@ -418,10 +418,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['claude_token'])) {
|
if (empty($extras['claude_token'])) {
|
||||||
$errorDesc = '机器人未启用。';
|
$errorContent = '机器人未启用。';
|
||||||
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
||||||
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
||||||
$errorDesc = '当前客户端版本低(所需版本≥v0.29.11)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.29.11)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Wenxin 机器人
|
// Wenxin 机器人
|
||||||
@ -435,10 +435,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['wenxin_key'])) {
|
if (empty($extras['wenxin_key'])) {
|
||||||
$errorDesc = '机器人未启用。';
|
$errorContent = '机器人未启用。';
|
||||||
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
||||||
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
||||||
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// QianWen 机器人
|
// QianWen 机器人
|
||||||
@ -451,10 +451,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['qianwen_key'])) {
|
if (empty($extras['qianwen_key'])) {
|
||||||
$errorDesc = '机器人未启用。';
|
$errorContent = '机器人未启用。';
|
||||||
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
||||||
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
||||||
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Gemini 机器人
|
// Gemini 机器人
|
||||||
@ -469,10 +469,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['gemini_key'])) {
|
if (empty($extras['gemini_key'])) {
|
||||||
$errorDesc = '机器人未启用。';
|
$errorContent = '机器人未启用。';
|
||||||
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
||||||
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
||||||
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// 智谱清言 机器人
|
// 智谱清言 机器人
|
||||||
@ -485,10 +485,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['zhipu_key'])) {
|
if (empty($extras['zhipu_key'])) {
|
||||||
$errorDesc = '机器人未启用。';
|
$errorContent = '机器人未启用。';
|
||||||
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
} elseif (in_array($this->client['platform'], ['win', 'mac', 'web'])
|
||||||
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
&& !Base::judgeClientVersion("0.29.11", $this->client['version'])) {
|
||||||
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
$errorContent = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// 其他机器人
|
// 其他机器人
|
||||||
@ -497,10 +497,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$webhookUrl = $userBot?->webhook_url;
|
$webhookUrl = $userBot?->webhook_url;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($errorDesc) {
|
if ($errorContent) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
'type' => 'desc',
|
'type' => 'content',
|
||||||
'desc' => $errorDesc,
|
'content' => $errorContent,
|
||||||
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,11 +84,28 @@ class CheckinRemindTask extends AbstractTask
|
|||||||
$dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid);
|
$dialog = WebSocketDialog::checkUserDialog($botUser, $user->userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
if ($type === 'exceed') {
|
if ($type === 'exceed') {
|
||||||
$text = "<p><strong style='color:red'>" . Doo::translate("缺卡提醒") . ":</strong>" . Doo::translate("上班时间到了,你还没有打卡哦~") . "</p>";
|
$title = '缺卡提醒';
|
||||||
|
$style = 'color:#f55;';
|
||||||
|
$content = '上班时间到了,你还没有打卡哦~';
|
||||||
} else {
|
} else {
|
||||||
$text = "<p><strong>" . Doo::translate("打卡提醒") . ":</strong>" . Doo::translate("快到上班时间了,别忘了打卡哦~") . "</p>";
|
$title = '打卡提醒';
|
||||||
|
$style = '';
|
||||||
|
$content = '快到上班时间了,别忘了打卡哦~';
|
||||||
}
|
}
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid);
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
|
'type' => 'content',
|
||||||
|
'title' => $title,
|
||||||
|
'content' => [
|
||||||
|
[
|
||||||
|
'content' => $title,
|
||||||
|
'style' => $style . 'font-weight:bold',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'content' => $content,
|
||||||
|
'style' => 'padding-top:4px;opacity:0.4',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
], $botUser->userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,7 +6,6 @@ use App\Models\User;
|
|||||||
use App\Module\Base;
|
use App\Module\Base;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\ProjectTask;
|
use App\Models\ProjectTask;
|
||||||
use App\Models\ProjectUser;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Models\WebSocketDialogMsg;
|
use App\Models\WebSocketDialogMsg;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
@ -64,8 +63,8 @@ class UnclaimedTaskRemindTask extends AbstractTask
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WebSocketDialogMsg::sendMsg(null, $project->dialog_id, 'template', [
|
WebSocketDialogMsg::sendMsg(null, $project->dialog_id, 'template', [
|
||||||
'type' => 'task_unclaimed',
|
'type' => 'task_list',
|
||||||
'desc' => '任务待领取',
|
'title' => '任务待领取',
|
||||||
'list' => $projectTasks->map(function ($item) {
|
'list' => $projectTasks->map(function ($item) {
|
||||||
return [
|
return [
|
||||||
'id' => $item->id,
|
'id' => $item->id,
|
||||||
|
|||||||
20
resources/assets/js/functions/web.js
vendored
20
resources/assets/js/functions/web.js
vendored
@ -411,7 +411,7 @@ import {MarkdownPreview} from "../store/markdown";
|
|||||||
case 'notice':
|
case 'notice':
|
||||||
return data.msg.notice
|
return data.msg.notice
|
||||||
case 'template':
|
case 'template':
|
||||||
return $A.L(data.msg.desc || '未知消息类型')
|
return $A.templateMsgSimpleDesc(data.msg)
|
||||||
default:
|
default:
|
||||||
return `[${$A.L('未知的消息')}]`
|
return `[${$A.L('未知的消息')}]`
|
||||||
}
|
}
|
||||||
@ -440,6 +440,24 @@ import {MarkdownPreview} from "../store/markdown";
|
|||||||
return `[${$A.L('文件')}] ${msg.name}`
|
return `[${$A.L('文件')}] ${msg.name}`
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板消息简单描述
|
||||||
|
* @param msg
|
||||||
|
* @returns {string|*}
|
||||||
|
*/
|
||||||
|
templateMsgSimpleDesc(msg) {
|
||||||
|
if (msg.title_raw) {
|
||||||
|
return msg.title_raw
|
||||||
|
}
|
||||||
|
if (msg.title) {
|
||||||
|
return $A.L(msg.title)
|
||||||
|
}
|
||||||
|
if (msg.type === 'content' && typeof msg.content === 'string' && msg.content !== '') {
|
||||||
|
return $A.L(msg.content)
|
||||||
|
}
|
||||||
|
return $A.L('未知的消息')
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件标题
|
* 获取文件标题
|
||||||
* @param file
|
* @param file
|
||||||
|
|||||||
@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<p v-for="(item, index) in items" :key="index" :style="item.style">{{ item.content }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
msg: Object,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
items({msg}) {
|
||||||
|
const {content} = msg;
|
||||||
|
if ($A.isArray(content)) {
|
||||||
|
return content.map(item => this.formatContent(item))
|
||||||
|
} else {
|
||||||
|
return [this.formatContent(content)];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formatContent(item) {
|
||||||
|
if ($A.isJson(item)) {
|
||||||
|
return {
|
||||||
|
content: item.language === false ? item.content : this.$L(item.content),
|
||||||
|
style: item.style || {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
content: this.$L(item),
|
||||||
|
style: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -1,16 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
{{$L(msg.desc)}}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
msg: Object,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
methods: {},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@ -24,10 +24,10 @@ import ApproveNotifier from "./approve-notifier.vue";
|
|||||||
import ApproveCommentNotifier from "./approve-comment-notifier.vue";
|
import ApproveCommentNotifier from "./approve-comment-notifier.vue";
|
||||||
import ApproveSubmitter from "./approve-submitter.vue";
|
import ApproveSubmitter from "./approve-submitter.vue";
|
||||||
|
|
||||||
import TaskUnclaimed from "./task-unclaimed.vue";
|
import TaskList from "./task-list.vue";
|
||||||
import FileDownload from "./file-download.vue";
|
import FileDownload from "./file-download.vue";
|
||||||
|
|
||||||
import Desc from "./desc.vue";
|
import Content from "./content.vue";
|
||||||
import Other from "./other.vue";
|
import Other from "./other.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -76,13 +76,13 @@ export default {
|
|||||||
case 'approve_submitter':
|
case 'approve_submitter':
|
||||||
return ApproveSubmitter;
|
return ApproveSubmitter;
|
||||||
|
|
||||||
case 'task_unclaimed':
|
case 'task_list':
|
||||||
return TaskUnclaimed;
|
return TaskList;
|
||||||
case 'file_download':
|
case 'file_download':
|
||||||
return FileDownload;
|
return FileDownload;
|
||||||
|
|
||||||
case 'desc':
|
case 'content':
|
||||||
return Desc;
|
return Content;
|
||||||
default:
|
default:
|
||||||
return Other;
|
return Other;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
{{$L("不支持的指令")}} <span class="warning-color">{{msg.type}}</span>,{{$L("你可以发送")}} <span class="mark-color">/help</span> {{$L("查看帮助菜单")}}。
|
{{$L("不支持的指令")}} <span class="warning-color">{{msg.type}}</span>,{{$L("你可以发送")}} <span class="mark-color">/help</span> {{$L("查看帮助菜单")}}。
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
{{$L("未知消息类型")}}
|
{{$L("未知的消息")}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<p>{{$L("任务待领取")}}</p>
|
<p>{{$L(msg.desc)}}</p>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
<p v-for="item in msg.list">
|
<p v-for="item in msg.list">
|
||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content-unknown">{{$L("未知的消息类型")}}</div>
|
<div class="content-unknown">{{$L("未知的消息")}}</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -3306,9 +3306,10 @@ export default {
|
|||||||
data = this.operateItem
|
data = this.operateItem
|
||||||
}
|
}
|
||||||
$A.modalConfirm({
|
$A.modalConfirm({
|
||||||
title: '下载文件',
|
language: false,
|
||||||
|
title: this.$L('下载文件'),
|
||||||
|
okText: this.$L('立即下载'),
|
||||||
content: `${data.msg.name} (${$A.bytesToSize(data.msg.size)})`,
|
content: `${data.msg.name} (${$A.bytesToSize(data.msg.size)})`,
|
||||||
okText: '立即下载',
|
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
this.$store.dispatch('downUrl', $A.apiUrl(`dialog/msg/download?msg_id=${data.id}`))
|
this.$store.dispatch('downUrl', $A.apiUrl(`dialog/msg/download?msg_id=${data.id}`))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1698,9 +1698,10 @@ export default {
|
|||||||
|
|
||||||
downFile(file) {
|
downFile(file) {
|
||||||
$A.modalConfirm({
|
$A.modalConfirm({
|
||||||
title: '下载文件',
|
language: false,
|
||||||
|
title: this.$L('下载文件'),
|
||||||
|
okText: this.$L('立即下载'),
|
||||||
content: `${file.name} (${$A.bytesToSize(file.size)})`,
|
content: `${file.name} (${$A.bytesToSize(file.size)})`,
|
||||||
okText: '立即下载',
|
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
this.$store.dispatch('downUrl', $A.apiUrl(`project/task/filedown?file_id=${file.id}`))
|
this.$store.dispatch('downUrl', $A.apiUrl(`project/task/filedown?file_id=${file.id}`))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1300,9 +1300,10 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$A.modalConfirm({
|
$A.modalConfirm({
|
||||||
title: '下载文件',
|
language: false,
|
||||||
|
title: this.$L('下载文件'),
|
||||||
|
okText: this.$L('立即下载'),
|
||||||
content: `${item.name}.${item.ext} (${$A.bytesToSize(item.size)})`,
|
content: `${item.name}.${item.ext} (${$A.bytesToSize(item.size)})`,
|
||||||
okText: '立即下载',
|
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
this.$store.dispatch('downUrl', $A.apiUrl(`file/content?id=${item.id}&down=yes`))
|
this.$store.dispatch('downUrl', $A.apiUrl(`file/content?id=${item.id}&down=yes`))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user