mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-21 16:00:31 +00:00
perf: 优化消息组件
This commit is contained in:
parent
c9d002c1cd
commit
153fd6c569
@ -966,7 +966,6 @@ class ApproveController extends AbstractController
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 审批机器人消息
|
// 审批机器人消息
|
||||||
public function approveMsg($type, $dialog, $botUser, $toUser, $process, $action = null)
|
public function approveMsg($type, $dialog, $botUser, $toUser, $process, $action = null)
|
||||||
{
|
{
|
||||||
@ -986,24 +985,31 @@ class ApproveController extends AbstractController
|
|||||||
'comment_content' => $process['comment_contents']['content'] ?? '',
|
'comment_content' => $process['comment_contents']['content'] ?? '',
|
||||||
'comment_pictures' => $process['comment_contents']['pictures'] ?? []
|
'comment_pictures' => $process['comment_contents']['pictures'] ?? []
|
||||||
];
|
];
|
||||||
$msg_action = null;
|
$msgAction = null;
|
||||||
$msg_data = [
|
$msgData = [
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'is_finished' => $process['is_finished'],
|
'is_finished' => $process['is_finished'],
|
||||||
'data' => $data
|
'data' => $data
|
||||||
];
|
];
|
||||||
|
$msgData['desc'] = match ($type) {
|
||||||
|
'approve_reviewer' => '待你审批',
|
||||||
|
'approve_notifier' => '审批通知',
|
||||||
|
'approve_comment_notifier' => '审批评论通知',
|
||||||
|
'approve_submitter' => '审批结果',
|
||||||
|
default => '不支持的指令',
|
||||||
|
};
|
||||||
if ($action == 'withdraw' || $action == 'pass' || $action == 'refuse') {
|
if ($action == 'withdraw' || $action == 'pass' || $action == 'refuse') {
|
||||||
// 任务完成,给发起人发送消息
|
// 任务完成,给发起人发送消息
|
||||||
if ($type == 'approve_submitter' && $action != 'withdraw') {
|
if ($type == 'approve_submitter' && $action != 'withdraw') {
|
||||||
return WebSocketDialogMsg::sendMsg($msg_action, $dialog->id, 'template', $msg_data, $botUser->userid, false, false, true);
|
return WebSocketDialogMsg::sendMsg($msgAction, $dialog->id, 'template', $msgData, $botUser->userid, false, false, true);
|
||||||
}
|
}
|
||||||
// 查找最后一条消息msg_id
|
// 查找最后一条消息msg_id
|
||||||
$msg_action = 'change-' . $toUser['msg_id'];
|
$msgAction = 'change-' . $toUser['msg_id'];
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
$msg = WebSocketDialogMsg::sendMsg($msg_action, $dialog->id, 'template', $msg_data, $process['start_user_id'], false, false, true);
|
$msg = WebSocketDialogMsg::sendMsg($msgAction, $dialog->id, 'template', $msgData, $process['start_user_id'], false, false, true);
|
||||||
// 关联信息
|
// 关联信息
|
||||||
if ($action == 'start') {
|
if ($action == 'start') {
|
||||||
$proc_msg = new ApproveProcMsg();
|
$proc_msg = new ApproveProcMsg();
|
||||||
|
|||||||
@ -117,7 +117,7 @@ class UserBot extends AbstractModel
|
|||||||
'label' => Doo::translate('帮助指令')
|
'label' => Doo::translate('帮助指令')
|
||||||
], [
|
], [
|
||||||
'key' => '/api',
|
'key' => '/api',
|
||||||
'label' => Doo::translate('Api接口文档')
|
'label' => Doo::translate('API接口文档')
|
||||||
], [
|
], [
|
||||||
'key' => '/list',
|
'key' => '/list',
|
||||||
'label' => Doo::translate('我的机器人')
|
'label' => Doo::translate('我的机器人')
|
||||||
|
|||||||
@ -591,7 +591,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return $data['msg']['notice'];
|
return $data['msg']['notice'];
|
||||||
|
|
||||||
case 'template':
|
case 'template':
|
||||||
return $this->previewTemplateMsg($data['msg']);
|
return Doo::translate($data['msg']['desc'] ?: '未知消息类型');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$action = Doo::translate("未知的消息");
|
$action = Doo::translate("未知的消息");
|
||||||
@ -617,55 +617,6 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
return "[{$action}] {$msg['name']}";
|
return "[{$action}] {$msg['name']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 预览模板消息
|
|
||||||
* @param $msg
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function previewTemplateMsg($msg)
|
|
||||||
{
|
|
||||||
switch ($msg['type']) {
|
|
||||||
case '/help':
|
|
||||||
return Doo::translate('帮助指令');
|
|
||||||
case '/list':
|
|
||||||
return Doo::translate('我的机器人');
|
|
||||||
case '/info':
|
|
||||||
return Doo::translate('机器人信息');
|
|
||||||
case '/newbot':
|
|
||||||
return Doo::translate('新建机器人');
|
|
||||||
case '/setname':
|
|
||||||
return Doo::translate('设置名称');
|
|
||||||
case '/deletebot':
|
|
||||||
return Doo::translate('删除机器人');
|
|
||||||
case '/token':
|
|
||||||
return Doo::translate('机器人Token');
|
|
||||||
case '/revoke':
|
|
||||||
return Doo::translate('更新Token');
|
|
||||||
case '/webhook':
|
|
||||||
return Doo::translate('设置Webhook');
|
|
||||||
case '/clearday':
|
|
||||||
return Doo::translate('设置保留消息时间');
|
|
||||||
case '/dialog':
|
|
||||||
return Doo::translate('对话列表');
|
|
||||||
case '/api':
|
|
||||||
return Doo::translate('API接口文档');
|
|
||||||
|
|
||||||
case 'approve_reviewer':
|
|
||||||
return Doo::translate('待你审批');
|
|
||||||
case 'approve_notifier':
|
|
||||||
return Doo::translate('审批通知');
|
|
||||||
case 'approve_comment_notifier':
|
|
||||||
return Doo::translate('审批评论通知');
|
|
||||||
case 'approve_submitter':
|
|
||||||
return Doo::translate('审批结果');
|
|
||||||
|
|
||||||
case 'notice':
|
|
||||||
return $msg['notice'];
|
|
||||||
default:
|
|
||||||
return Doo::translate(preg_match("/^\//", $msg['type']) ? '帮助菜单' : '未知消息类型');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成关键词
|
* 生成关键词
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@ -95,14 +95,20 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
if ($botUser->email === 'check-in@bot.system') {
|
if ($botUser->email === 'check-in@bot.system') {
|
||||||
$text = UserBot::checkinBotQuickMsg($command, $msg->userid);
|
$text = UserBot::checkinBotQuickMsg($command, $msg->userid);
|
||||||
if ($text) {
|
if ($text) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $text], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
|
'type' => 'desc',
|
||||||
|
'desc' => $text,
|
||||||
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 隐私机器人
|
// 隐私机器人
|
||||||
if ($botUser->email === 'anon-msg@bot.system') {
|
if ($botUser->email === 'anon-msg@bot.system') {
|
||||||
$text = UserBot::anonBotQuickMsg($command);
|
$text = UserBot::anonBotQuickMsg($command);
|
||||||
if ($text) {
|
if ($text) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $text], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
|
'type' => 'desc',
|
||||||
|
'desc' => $text,
|
||||||
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 管理机器人
|
// 管理机器人
|
||||||
@ -113,14 +119,17 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$isManager = false;
|
$isManager = false;
|
||||||
} else {
|
} else {
|
||||||
$text = "非常抱歉,我不是你的机器人,无法完成你的指令。";
|
$text = "非常抱歉,我不是你的机器人,无法完成你的指令。";
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $text], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
|
'type' => 'desc',
|
||||||
|
'desc' => $text,
|
||||||
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$array = Base::newTrim(explode(" ", "{$command} "));
|
$array = Base::newTrim(explode(" ", "{$command} "));
|
||||||
$type = $array[0];
|
$type = $array[0];
|
||||||
$data = [];
|
$data = [];
|
||||||
$notice = "";
|
$desc = "";
|
||||||
if (!$isManager && in_array($type, ['/list', '/newbot'])) {
|
if (!$isManager && in_array($type, ['/list', '/newbot'])) {
|
||||||
return; // 这些操作仅支持【机器人管理】机器人
|
return; // 这些操作仅支持【机器人管理】机器人
|
||||||
}
|
}
|
||||||
@ -143,20 +152,19 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->get();
|
->get();
|
||||||
if ($data->isEmpty()) {
|
if ($data->isEmpty()) {
|
||||||
$type = "notice";
|
$desc = "您没有创建机器人。";
|
||||||
$notice = "您没有创建机器人。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详情
|
* 详情
|
||||||
*/
|
*/
|
||||||
|
case '/hello':
|
||||||
case '/info':
|
case '/info':
|
||||||
$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) {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -169,27 +177,27 @@ 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) {
|
||||||
$type = "notice";
|
$desc = "超过最大创建数量。";
|
||||||
$notice = "超过最大创建数量。";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strlen($array[1]) < 2 || strlen($array[1]) > 20) {
|
if (strlen($array[1]) < 2 || strlen($array[1]) > 20) {
|
||||||
$type = "notice";
|
$desc = "机器人名称由2-20个字符组成。";
|
||||||
$notice = "机器人名称由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)) {
|
||||||
$type = "notice";
|
$desc = "创建失败。";
|
||||||
$notice = "创建失败。";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dialog = WebSocketDialog::checkUserDialog($data, $msg->userid);
|
$dialog = WebSocketDialog::checkUserDialog($data, $msg->userid);
|
||||||
if ($dialog) {
|
if ($dialog) {
|
||||||
$text = "<p>您好,我是机器人:{$data->nickname},我的机器人ID是:{$data->userid},</p><p>你可以发送 <u><b>/help</b></u> 查看我支持什么命令。</p>";
|
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
|
||||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $data->userid); // todo 未能在任务end事件来发送任务
|
'type' => '/hello',
|
||||||
|
'desc' => '创建成功。',
|
||||||
|
'data' => $data,
|
||||||
|
], $data->userid); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -200,8 +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) {
|
||||||
$type = "notice";
|
$desc = "机器人名称由2-20个字符组成。";
|
||||||
$notice = "机器人名称由2-20个字符组成。";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$data = $this->botManagerOne($botId, $msg->userid);
|
$data = $this->botManagerOne($botId, $msg->userid);
|
||||||
@ -211,8 +218,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->pinyin = Base::cn2pinyin($nameString);
|
$data->pinyin = Base::cn2pinyin($nameString);
|
||||||
$data->save();
|
$data->save();
|
||||||
} else {
|
} else {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -226,8 +232,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
if ($data) {
|
if ($data) {
|
||||||
$data->deleteUser('delete bot');
|
$data->deleteUser('delete bot');
|
||||||
} else {
|
} else {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -240,8 +245,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
if ($data) {
|
if ($data) {
|
||||||
User::generateToken($data);
|
User::generateToken($data);
|
||||||
} else {
|
} else {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -256,8 +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 {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -278,8 +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 {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -291,8 +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) {
|
||||||
$type = "notice";
|
$desc = "webhook地址最长仅支持255个字符。";
|
||||||
$notice = "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) {
|
||||||
@ -303,8 +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 {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -325,8 +325,7 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
->take(20)
|
->take(20)
|
||||||
->get();
|
->get();
|
||||||
if ($list->isEmpty()) {
|
if ($list->isEmpty()) {
|
||||||
$type = "notice";
|
$desc = "没有搜索到相关会话。";
|
||||||
$notice = "没有搜索到相关会话。";
|
|
||||||
} 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);
|
||||||
@ -334,19 +333,45 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$data->list = $list; // 这个参数只是作为输出,所以不保存
|
$data->list = $list; // 这个参数只是作为输出,所以不保存
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$type = "notice";
|
$desc = "机器人不存在。";
|
||||||
$notice = "机器人不存在。";
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
|
||||||
'type' => $type,
|
if ($desc) {
|
||||||
'data' => $data,
|
$msgData = [
|
||||||
'notice' => $notice,
|
'type' => 'desc',
|
||||||
'manager' => $isManager,
|
'desc' => $desc,
|
||||||
'version' => Base::getVersion()
|
];
|
||||||
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
} else {
|
||||||
|
$msgData = [
|
||||||
|
'type' => $type,
|
||||||
|
'data' => $data,
|
||||||
|
];
|
||||||
|
$msgData['desc'] = match ($type) {
|
||||||
|
'/hello' => '您好',
|
||||||
|
'/help' => '帮助指令',
|
||||||
|
'/list' => '我的机器人',
|
||||||
|
'/info' => '机器人信息',
|
||||||
|
'/newbot' => '新建机器人',
|
||||||
|
'/setname' => '设置名称',
|
||||||
|
'/deletebot' => '删除机器人',
|
||||||
|
'/token' => '机器人Token',
|
||||||
|
'/revoke' => '更新Token',
|
||||||
|
'/webhook' => '设置Webhook',
|
||||||
|
'/clearday' => '设置保留消息时间',
|
||||||
|
'/dialog' => '对话列表',
|
||||||
|
'/api' => 'API接口文档',
|
||||||
|
default => '不支持的指令',
|
||||||
|
};
|
||||||
|
if ($type == '/api') {
|
||||||
|
$msgData['version'] = Base::getVersion();
|
||||||
|
} elseif ($type == '/help') {
|
||||||
|
$msgData['manager'] = $isManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', $msgData, $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,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 = [];
|
||||||
$error = null;
|
$errorDesc = null;
|
||||||
switch ($botUser->email) {
|
switch ($botUser->email) {
|
||||||
// ChatGPT 机器人
|
// ChatGPT 机器人
|
||||||
case 'ai-openai@bot.system':
|
case 'ai-openai@bot.system':
|
||||||
@ -377,10 +402,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'chunk_size' => 7,
|
'chunk_size' => 7,
|
||||||
];
|
];
|
||||||
if (empty($extras['openai_key'])) {
|
if (empty($extras['openai_key'])) {
|
||||||
$error = 'Robot disabled.';
|
$errorDesc = '机器人未启用。';
|
||||||
} 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'])) {
|
||||||
$error = 'The client version is low (required version ≥ v0.29.11).';
|
$errorDesc = '当前客户端版本低(所需版本≥v0.29.11)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Claude 机器人
|
// Claude 机器人
|
||||||
@ -393,10 +418,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['claude_token'])) {
|
if (empty($extras['claude_token'])) {
|
||||||
$error = 'Robot disabled.';
|
$errorDesc = '机器人未启用。';
|
||||||
} 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'])) {
|
||||||
$error = 'The client version is low (required version ≥ v0.29.11).';
|
$errorDesc = '当前客户端版本低(所需版本≥v0.29.11)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Wenxin 机器人
|
// Wenxin 机器人
|
||||||
@ -410,10 +435,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['wenxin_key'])) {
|
if (empty($extras['wenxin_key'])) {
|
||||||
$error = 'Robot disabled.';
|
$errorDesc = '机器人未启用。';
|
||||||
} 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'])) {
|
||||||
$error = 'The client version is low (required version ≥ v0.29.12).';
|
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// QianWen 机器人
|
// QianWen 机器人
|
||||||
@ -426,10 +451,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['qianwen_key'])) {
|
if (empty($extras['qianwen_key'])) {
|
||||||
$error = 'Robot disabled.';
|
$errorDesc = '机器人未启用。';
|
||||||
} 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'])) {
|
||||||
$error = 'The client version is low (required version ≥ v0.29.12).';
|
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Gemini 机器人
|
// Gemini 机器人
|
||||||
@ -444,10 +469,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['gemini_key'])) {
|
if (empty($extras['gemini_key'])) {
|
||||||
$error = 'Robot disabled.';
|
$errorDesc = '机器人未启用。';
|
||||||
} 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'])) {
|
||||||
$error = 'The client version is low (required version ≥ v0.29.12).';
|
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// 智谱清言 机器人
|
// 智谱清言 机器人
|
||||||
@ -460,10 +485,10 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
'server_url' => $serverUrl,
|
'server_url' => $serverUrl,
|
||||||
];
|
];
|
||||||
if (empty($extras['zhipu_key'])) {
|
if (empty($extras['zhipu_key'])) {
|
||||||
$error = 'Robot disabled.';
|
$errorDesc = '机器人未启用。';
|
||||||
} 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'])) {
|
||||||
$error = 'The client version is low (required version ≥ v0.29.12).';
|
$errorDesc = '当前客户端版本低(所需版本≥v0.29.12)。';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// 其他机器人
|
// 其他机器人
|
||||||
@ -472,8 +497,11 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$webhookUrl = $userBot?->webhook_url;
|
$webhookUrl = $userBot?->webhook_url;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($error) {
|
if ($errorDesc) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $error], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
|
||||||
|
'type' => 'desc',
|
||||||
|
'desc' => $errorDesc,
|
||||||
|
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!preg_match("/^https*:\/\//", $webhookUrl)) {
|
if (!preg_match("/^https*:\/\//", $webhookUrl)) {
|
||||||
@ -498,13 +526,13 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$userBot->webhook_num++;
|
$userBot->webhook_num++;
|
||||||
$userBot->save();
|
$userBot->save();
|
||||||
}
|
}
|
||||||
if($res['data'] && $data = json_decode($res['data'])){
|
if ($res['data'] && $data = json_decode($res['data'])) {
|
||||||
if($data['code'] != 200 && $data['message']){
|
if ($data['code'] != 200 && $data['message']) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $res['data']['message']], $botUser->userid, false, false, true);
|
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $res['data']['message']], $botUser->userid, false, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
//throw $th;
|
info($th->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class UnclaimedTaskRemindTask extends AbstractTask
|
|||||||
Project::whereNull('deleted_at')->whereNull('archived_at')->chunk(100, function ($projects) {
|
Project::whereNull('deleted_at')->whereNull('archived_at')->chunk(100, function ($projects) {
|
||||||
foreach ($projects as $project) {
|
foreach ($projects as $project) {
|
||||||
//
|
//
|
||||||
$projectTasks = ProjectTask::select('project_tasks.id', 'project_tasks.name')
|
$projectTasks = ProjectTask::select(['project_tasks.id', 'project_tasks.name'])
|
||||||
->leftJoin('project_task_users', function ($query) {
|
->leftJoin('project_task_users', function ($query) {
|
||||||
$query->on('project_tasks.id', '=', 'project_task_users.task_id');
|
$query->on('project_tasks.id', '=', 'project_task_users.task_id');
|
||||||
})
|
})
|
||||||
@ -68,12 +68,15 @@ class UnclaimedTaskRemindTask extends AbstractTask
|
|||||||
$project->syncDialogUser();
|
$project->syncDialogUser();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$taskHtml = '<span style="line-height: 26px;">任务待领取</span> <br/>';
|
WebSocketDialogMsg::sendMsg(null, $project->dialog_id, 'template', [
|
||||||
foreach ($projectTasks as $projectTask) {
|
'type' => 'task_unclaimed',
|
||||||
$taskHtml .= "<span class=\"mention task\" style=\"line-height: 26px;\" data-id=\"{$projectTask->id}\">#{$projectTask->name}</span> <br/>";
|
'desc' => '任务待领取',
|
||||||
}
|
'list' => $projectTasks->map(function ($item) {
|
||||||
WebSocketDialogMsg::sendMsg(null, $project->dialog_id, 'text', [
|
return [
|
||||||
'text' => $taskHtml
|
'id' => $item->id,
|
||||||
|
'name' => $item->name,
|
||||||
|
];
|
||||||
|
}),
|
||||||
], $botUser->userid);
|
], $botUser->userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -431,9 +431,8 @@ IT资讯
|
|||||||
36氪
|
36氪
|
||||||
60s读世界
|
60s读世界
|
||||||
|
|
||||||
Api接口文档
|
|
||||||
我的机器人
|
我的机器人
|
||||||
Api接口文档
|
API接口文档
|
||||||
帮助指令
|
帮助指令
|
||||||
使用说明
|
使用说明
|
||||||
隐私说明
|
隐私说明
|
||||||
@ -531,3 +530,36 @@ OKR提醒
|
|||||||
上班时间到了,你还没有打卡哦~
|
上班时间到了,你还没有打卡哦~
|
||||||
快到上班时间了,别忘了打卡哦~
|
快到上班时间了,别忘了打卡哦~
|
||||||
|
|
||||||
|
|
||||||
|
任务待领取
|
||||||
|
非常抱歉,我不是你的机器人,无法完成你的指令。
|
||||||
|
您没有创建机器人。
|
||||||
|
机器人不存在。
|
||||||
|
超过最大创建数量。
|
||||||
|
机器人名称由2-20个字符组成。
|
||||||
|
创建失败。
|
||||||
|
创建成功。
|
||||||
|
webhook地址最长仅支持255个字符。
|
||||||
|
没有搜索到相关会话。
|
||||||
|
您好
|
||||||
|
帮助指令
|
||||||
|
我的机器人
|
||||||
|
机器人信息
|
||||||
|
新建机器人
|
||||||
|
设置名称
|
||||||
|
删除机器人
|
||||||
|
机器人Token
|
||||||
|
更新Token
|
||||||
|
设置Webhook
|
||||||
|
设置保留消息时间
|
||||||
|
对话列表
|
||||||
|
API接口文档
|
||||||
|
不支持的指令
|
||||||
|
机器人未启用。
|
||||||
|
当前客户端版本低(所需版本≥(*))。
|
||||||
|
审批结果
|
||||||
|
审批评论通知
|
||||||
|
审批通知
|
||||||
|
待你审批
|
||||||
|
未知的消息
|
||||||
|
未知消息类型
|
||||||
|
|||||||
@ -1616,3 +1616,36 @@ License Key
|
|||||||
未知错误
|
未知错误
|
||||||
网络异常,请重试。
|
网络异常,请重试。
|
||||||
请求失败,请重试。
|
请求失败,请重试。
|
||||||
|
|
||||||
|
任务待领取
|
||||||
|
非常抱歉,我不是你的机器人,无法完成你的指令。
|
||||||
|
您没有创建机器人。
|
||||||
|
机器人不存在。
|
||||||
|
超过最大创建数量。
|
||||||
|
机器人名称由2-20个字符组成。
|
||||||
|
创建失败。
|
||||||
|
创建成功。
|
||||||
|
webhook地址最长仅支持255个字符。
|
||||||
|
没有搜索到相关会话。
|
||||||
|
您好
|
||||||
|
帮助指令
|
||||||
|
我的机器人
|
||||||
|
机器人信息
|
||||||
|
新建机器人
|
||||||
|
设置名称
|
||||||
|
删除机器人
|
||||||
|
机器人Token
|
||||||
|
更新Token
|
||||||
|
设置Webhook
|
||||||
|
设置保留消息时间
|
||||||
|
对话列表
|
||||||
|
API接口文档
|
||||||
|
不支持的指令
|
||||||
|
机器人未启用。
|
||||||
|
当前客户端版本低(所需版本≥(*))。
|
||||||
|
审批结果
|
||||||
|
审批评论通知
|
||||||
|
审批通知
|
||||||
|
待你审批
|
||||||
|
未知的消息
|
||||||
|
未知消息类型
|
||||||
|
|||||||
@ -16432,9 +16432,9 @@
|
|||||||
"ru": "60 человек читают мир"
|
"ru": "60 человек читают мир"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "Api接口文档",
|
"key": "API接口文档",
|
||||||
"zh": "",
|
"zh": "",
|
||||||
"zh-CHT": "Api接口文檔",
|
"zh-CHT": "API接口文檔",
|
||||||
"en": "Api interface documentation",
|
"en": "Api interface documentation",
|
||||||
"ko": "Api 인터페이스 문서",
|
"ko": "Api 인터페이스 문서",
|
||||||
"ja": "Apiインタフェース文書です",
|
"ja": "Apiインタフェース文書です",
|
||||||
@ -22742,4 +22742,4 @@
|
|||||||
"id": "Sudah hampir waktunya bekerja, jangan lupa untuk meninju jam oh ~",
|
"id": "Sudah hampir waktunya bekerja, jangan lupa untuk meninju jam oh ~",
|
||||||
"ru": "Пора на работу, не забудь отметиться"
|
"ru": "Пора на работу, не забудь отметиться"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
50
resources/assets/js/functions/web.js
vendored
50
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.tempMsgSimpleDesc(data.msg)
|
return $A.L(data.msg.desc || '未知消息类型')
|
||||||
default:
|
default:
|
||||||
return `[${$A.L('未知的消息')}]`
|
return `[${$A.L('未知的消息')}]`
|
||||||
}
|
}
|
||||||
@ -440,54 +440,6 @@ import {MarkdownPreview} from "../store/markdown";
|
|||||||
return `[${$A.L('文件')}] ${msg.name}`
|
return `[${$A.L('文件')}] ${msg.name}`
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 模板消息简单描述
|
|
||||||
* @param msg
|
|
||||||
* @returns {string|*}
|
|
||||||
*/
|
|
||||||
tempMsgSimpleDesc(msg) {
|
|
||||||
switch (msg.type) {
|
|
||||||
case '/help':
|
|
||||||
return $A.L('帮助指令');
|
|
||||||
case '/list':
|
|
||||||
return $A.L('我的机器人');
|
|
||||||
case '/info':
|
|
||||||
return $A.L('机器人信息');
|
|
||||||
case '/newbot':
|
|
||||||
return $A.L('新建机器人');
|
|
||||||
case '/setname':
|
|
||||||
return $A.L('设置名称');
|
|
||||||
case '/deletebot':
|
|
||||||
return $A.L('删除机器人');
|
|
||||||
case '/token':
|
|
||||||
return $A.L('机器人Token');
|
|
||||||
case '/revoke':
|
|
||||||
return $A.L('更新Token');
|
|
||||||
case '/webhook':
|
|
||||||
return $A.L('设置Webhook');
|
|
||||||
case '/clearday':
|
|
||||||
return $A.L('设置保留消息时间');
|
|
||||||
case '/dialog':
|
|
||||||
return $A.L('对话列表');
|
|
||||||
case '/api':
|
|
||||||
return $A.L('API接口文档');
|
|
||||||
|
|
||||||
case 'approve_reviewer':
|
|
||||||
return $A.L('待你审批');
|
|
||||||
case 'approve_notifier':
|
|
||||||
return $A.L('审批通知');
|
|
||||||
case 'approve_comment_notifier':
|
|
||||||
return $A.L('审批评论通知');
|
|
||||||
case 'approve_submitter':
|
|
||||||
return $A.L('审批结果');
|
|
||||||
|
|
||||||
case 'notice':
|
|
||||||
return msg.notice;
|
|
||||||
default:
|
|
||||||
return $A.L(/^\//.test(msg.type) ? '帮助菜单' : '未知消息类型');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件标题
|
* 获取文件标题
|
||||||
* @param file
|
* @param file
|
||||||
|
|||||||
@ -51,7 +51,6 @@
|
|||||||
@on-view-text="onViewText"
|
@on-view-text="onViewText"
|
||||||
@on-view-file="onViewFile"
|
@on-view-file="onViewFile"
|
||||||
@on-down-file="onDownFile"
|
@on-down-file="onDownFile"
|
||||||
@on-click-template="onClickTemplate"
|
|
||||||
@on-reply-list="onReplyList"
|
@on-reply-list="onReplyList"
|
||||||
@on-error="onError"
|
@on-error="onError"
|
||||||
@on-emoji="onEmoji"
|
@on-emoji="onEmoji"
|
||||||
@ -253,10 +252,6 @@ export default {
|
|||||||
this.dispatch("on-down-file", data)
|
this.dispatch("on-down-file", data)
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickTemplate(e) {
|
|
||||||
this.dispatch("on-click-template", e)
|
|
||||||
},
|
|
||||||
|
|
||||||
onReplyList(data) {
|
onReplyList(data) {
|
||||||
this.dispatch("on-reply-list", data)
|
this.dispatch("on-reply-list", data)
|
||||||
},
|
},
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
<!--投票-->
|
<!--投票-->
|
||||||
<VoteMsg v-else-if="msgData.type === 'vote'" :msg="msgData.msg" :voteData="voteData" @onVote="onVote($event, msgData)"/>
|
<VoteMsg v-else-if="msgData.type === 'vote'" :msg="msgData.msg" :voteData="voteData" @onVote="onVote($event, msgData)"/>
|
||||||
<!--模板-->
|
<!--模板-->
|
||||||
<TemplateMsg v-else-if="msgData.type === 'template'" :msg="msgData.msg" @clickTemplate="clickTemplate"/>
|
<TemplateMsg v-else-if="msgData.type === 'template'" :msg="msgData.msg" @viewText="viewText"/>
|
||||||
<!--等待-->
|
<!--等待-->
|
||||||
<LoadMsg v-else-if="isLoading" :error="msgData.error"/>
|
<LoadMsg v-else-if="isLoading" :error="msgData.error"/>
|
||||||
<!--未知-->
|
<!--未知-->
|
||||||
@ -598,10 +598,6 @@ export default {
|
|||||||
this.$set(msgData.msg, '_loadIng', 0)
|
this.$set(msgData.msg, '_loadIng', 0)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
clickTemplate(e) {
|
|
||||||
this.$emit("on-click-template", e)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<p><b>发送文本消息:</b></p>
|
<p><b>发送文本消息:</b></p>
|
||||||
<p>curl --request POST '{{ $A.apiUrl('dialog/msg/sendtext') }}' \</p>
|
<p>curl --request POST '{{ $A.apiUrl('dialog/msg/sendtext') }}' \</p>
|
||||||
<p>--header 'version: {{ $version }}' \</p>
|
<p>--header 'version: {{ msg.version }}' \</p>
|
||||||
<p>--header 'token: <span class="mark-color">{机器人Token}</span>' \</p>
|
<p>--header 'token: <span class="mark-color">{机器人Token}</span>' \</p>
|
||||||
<p>--form 'dialog_id="<span class="mark-color">{对话ID}</span>"' \</p>
|
<p>--form 'dialog_id="<span class="mark-color">{对话ID}</span>"' \</p>
|
||||||
<p>--form 'text="<span class="mark-color">{消息内容}</span>"'</p>
|
<p>--form 'text="<span class="mark-color">{消息内容}</span>"'</p>
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
您好,我是机器人:{{msg.data.nickname}},我的机器人ID是:{{msg.data.userid}},你可以发送 <span class="mark-color">/help</span> 查看我支持什么命令。
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
msg: Object,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
<p><span class="mark-color">/setname{{IDLabel}} {机器人名称}</span> - 修改机器人名称</p>
|
<p><span class="mark-color">/setname{{IDLabel}} {机器人名称}</span> - 修改机器人名称</p>
|
||||||
<p><span class="mark-color">/deletebot{{IDLabel}}</span> - 删除机器人</p>
|
<p><span class="mark-color">/deletebot{{IDLabel}}</span> - 删除机器人</p>
|
||||||
<p><span class="mark-color">/clearday{{IDLabel}} {天数}</span> - 设置保留消息时间(默认30天)</p>
|
<p><span class="mark-color">/clearday{{IDLabel}} {天数}</span> - 设置保留消息时间(默认30天)</p>
|
||||||
<p><span class="mark-color">/webhook{{IDLabel}} [url]</span> - 设置消息Webhook(详情请看 <u>Api接口文档</u>)</p>
|
<p><span class="mark-color">/webhook{{IDLabel}} [url]</span> - 设置消息Webhook(详情请看 <u>API接口文档</u>)</p>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
<p><b>机器人设置</b></p>
|
<p><b>机器人设置</b></p>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<p><span class="mark-color">/dialog{{IDLabel}} [搜索关键词]</span> - 查看会话ID</p>
|
<p><span class="mark-color">/dialog{{IDLabel}} [搜索关键词]</span> - 查看会话ID</p>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
<p><b>Api接口文档</b></p>
|
<p><b>API接口文档</b></p>
|
||||||
<p><span class="mark-color">/api</span> - 查看接口列表</p>
|
<p><span class="mark-color">/api</span> - 查看接口列表</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
{{msg.notice}}
|
{{$L(msg.desc)}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@ -1,10 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="`content-template no-dark-content ${msg.type}`" @click="onClick">
|
<div :class="`content-template no-dark-content ${msg.type}`" @click="viewText">
|
||||||
<component :is="currentTemplate" :msg="msg"/>
|
<component :is="currentTemplate" :msg="msg"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import BotHello from "./bot-hello.vue";
|
||||||
import BotHelp from "./bot-help.vue";
|
import BotHelp from "./bot-help.vue";
|
||||||
import BotList from "./bot-list.vue";
|
import BotList from "./bot-list.vue";
|
||||||
import BotInfo from "./bot-info.vue";
|
import BotInfo from "./bot-info.vue";
|
||||||
@ -17,11 +18,15 @@ import BotWebhook from "./bot-webhook.vue";
|
|||||||
import BotClearday from "./bot-clearday.vue";
|
import BotClearday from "./bot-clearday.vue";
|
||||||
import BotDialog from "./bot-dialog.vue";
|
import BotDialog from "./bot-dialog.vue";
|
||||||
import BotApi from "./bot-api.vue";
|
import BotApi from "./bot-api.vue";
|
||||||
import Notice from "./notice.vue";
|
|
||||||
import ApproveReviewer from "./approve-reviewer.vue";
|
import ApproveReviewer from "./approve-reviewer.vue";
|
||||||
import ApproveNotifier from "./approve-notifier.vue";
|
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 Desc from "./desc.vue";
|
||||||
import Other from "./other.vue";
|
import Other from "./other.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -34,6 +39,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
currentTemplate() {
|
currentTemplate() {
|
||||||
switch (this.msg.type) {
|
switch (this.msg.type) {
|
||||||
|
case '/hello':
|
||||||
|
return BotHello;
|
||||||
case '/help':
|
case '/help':
|
||||||
return BotHelp;
|
return BotHelp;
|
||||||
case '/list':
|
case '/list':
|
||||||
@ -68,16 +75,19 @@ export default {
|
|||||||
case 'approve_submitter':
|
case 'approve_submitter':
|
||||||
return ApproveSubmitter;
|
return ApproveSubmitter;
|
||||||
|
|
||||||
case 'notice':
|
case 'task_unclaimed':
|
||||||
return Notice;
|
return TaskUnclaimed;
|
||||||
|
|
||||||
|
case 'desc':
|
||||||
|
return Desc;
|
||||||
default:
|
default:
|
||||||
return Other;
|
return Other;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onClick(e) {
|
viewText(e) {
|
||||||
this.$emit('clickTemplate', e);
|
this.$emit('viewText', e);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="isBot">
|
<div v-if="isBot">
|
||||||
你好,我是你的机器人助理,你可以发送 <span class="mark-color">/help</span> 查看帮助菜单。
|
不支持的指令 <span class="warning-color">{{msg.type}}</span>,你可以发送 <span class="mark-color">/help</span> 查看帮助菜单。
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
未知消息类型
|
未知消息类型
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<p>任务待领取</p>
|
||||||
|
<p> </p>
|
||||||
|
|
||||||
|
<p v-for="item in msg.list">
|
||||||
|
<span class="mention task" :data-id="item.id">#{{item.name}}</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
msg: Object,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
methods: {},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -204,7 +204,6 @@
|
|||||||
@on-view-text="onViewText"
|
@on-view-text="onViewText"
|
||||||
@on-view-file="onViewFile"
|
@on-view-file="onViewFile"
|
||||||
@on-down-file="onDownFile"
|
@on-down-file="onDownFile"
|
||||||
@on-click-template="onClickTemplate"
|
|
||||||
@on-reply-list="onReplyList"
|
@on-reply-list="onReplyList"
|
||||||
@on-error="onError"
|
@on-error="onError"
|
||||||
@on-emoji="onEmoji"
|
@on-emoji="onEmoji"
|
||||||
@ -3122,8 +3121,17 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.onClickTemplate({target})) {
|
// 打开审批详情
|
||||||
return;
|
let approveElement = target;
|
||||||
|
while (approveElement) {
|
||||||
|
if (approveElement.classList.contains('dialog-scroller')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (approveElement.classList.contains('open-approve-details')) {
|
||||||
|
Store.set('approveDetails', approveElement.getAttribute("data-id"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
approveElement = approveElement.parentElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (target.nodeName) {
|
switch (target.nodeName) {
|
||||||
@ -3307,26 +3315,6 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickTemplate({target}) {
|
|
||||||
if (this.operateVisible) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 打开审批详情
|
|
||||||
let approveElement = target;
|
|
||||||
while (approveElement) {
|
|
||||||
if (approveElement.classList.contains('dialog-scroller')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (approveElement.classList.contains('open-approve-details')) {
|
|
||||||
Store.set('approveDetails', approveElement.getAttribute("data-id"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
approveElement = approveElement.parentElement;
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
|
|
||||||
onReplyList(data) {
|
onReplyList(data) {
|
||||||
if (this.operateVisible) {
|
if (this.operateVisible) {
|
||||||
return
|
return
|
||||||
|
|||||||
18
resources/assets/sass/dark.scss
vendored
18
resources/assets/sass/dark.scss
vendored
@ -250,15 +250,6 @@ body.dark-mode-reverse {
|
|||||||
a {
|
a {
|
||||||
color: #0027a1;
|
color: #0027a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mention {
|
|
||||||
color: #000000;
|
|
||||||
|
|
||||||
&.file,
|
|
||||||
&[data-denotation-char="~"] {
|
|
||||||
color: #0027a1 !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +267,15 @@ body.dark-mode-reverse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mention {
|
||||||
|
color: #000000;
|
||||||
|
|
||||||
|
&.file,
|
||||||
|
&[data-denotation-char="~"] {
|
||||||
|
color: #0027a1 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-emoji {
|
.dialog-emoji {
|
||||||
|
|||||||
@ -915,40 +915,6 @@
|
|||||||
max-height: 150px;
|
max-height: 150px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.mention {
|
|
||||||
color: $flow-status-end-color;
|
|
||||||
background-color: transparent;
|
|
||||||
user-select: inherit;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
> span {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.task,&.okr {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.file,
|
|
||||||
&[data-denotation-char="~"] {
|
|
||||||
color: #436FF6 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.user {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.me {
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
padding: 3px 4px;
|
|
||||||
color: #ffffff;
|
|
||||||
white-space: nowrap;
|
|
||||||
background-color: $primary-color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1206,6 +1172,9 @@
|
|||||||
|
|
||||||
.content-template {
|
.content-template {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
.warning-color {
|
||||||
|
color: $flow-status-start-color;
|
||||||
|
}
|
||||||
.mark-color {
|
.mark-color {
|
||||||
color: $primary-color;
|
color: $primary-color;
|
||||||
}
|
}
|
||||||
@ -1435,6 +1404,40 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mention {
|
||||||
|
color: $flow-status-end-color;
|
||||||
|
background-color: transparent;
|
||||||
|
user-select: inherit;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
> span {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.task,&.okr {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.file,
|
||||||
|
&[data-denotation-char="~"] {
|
||||||
|
color: #436FF6 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.user {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.me {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 3px 4px;
|
||||||
|
color: #ffffff;
|
||||||
|
white-space: nowrap;
|
||||||
|
background-color: $primary-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-emoji {
|
.dialog-emoji {
|
||||||
@ -1680,19 +1683,6 @@
|
|||||||
.dialog-content {
|
.dialog-content {
|
||||||
.content-text {
|
.content-text {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
|
|
||||||
> pre {
|
|
||||||
.mention {
|
|
||||||
color: $primary-title-color;
|
|
||||||
|
|
||||||
&.me {
|
|
||||||
font-size: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
padding: inherit;
|
|
||||||
background-color: inherit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-record {
|
.content-record {
|
||||||
@ -1757,6 +1747,17 @@
|
|||||||
border-color: #f3f3f3;
|
border-color: #f3f3f3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mention {
|
||||||
|
color: $primary-title-color;
|
||||||
|
|
||||||
|
&.me {
|
||||||
|
font-size: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
padding: inherit;
|
||||||
|
background-color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-emoji {
|
.dialog-emoji {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user