perf: 优化消息组件

This commit is contained in:
kuaifan 2024-10-17 12:43:52 +08:00
parent c9d002c1cd
commit 153fd6c569
21 changed files with 315 additions and 279 deletions

View File

@ -966,7 +966,6 @@ class ApproveController extends AbstractController
return $res;
}
// 审批机器人消息
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_pictures' => $process['comment_contents']['pictures'] ?? []
];
$msg_action = null;
$msg_data = [
$msgAction = null;
$msgData = [
'type' => $type,
'action' => $action,
'is_finished' => $process['is_finished'],
'data' => $data
];
$msgData['desc'] = match ($type) {
'approve_reviewer' => '待你审批',
'approve_notifier' => '审批通知',
'approve_comment_notifier' => '审批评论通知',
'approve_submitter' => '审批结果',
default => '不支持的指令',
};
if ($action == 'withdraw' || $action == 'pass' || $action == 'refuse') {
// 任务完成,给发起人发送消息
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_action = 'change-' . $toUser['msg_id'];
$msgAction = 'change-' . $toUser['msg_id'];
}
//
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') {
$proc_msg = new ApproveProcMsg();

View File

@ -117,7 +117,7 @@ class UserBot extends AbstractModel
'label' => Doo::translate('帮助指令')
], [
'key' => '/api',
'label' => Doo::translate('Api接口文档')
'label' => Doo::translate('API接口文档')
], [
'key' => '/list',
'label' => Doo::translate('我的机器人')

View File

@ -591,7 +591,7 @@ class WebSocketDialogMsg extends AbstractModel
return $data['msg']['notice'];
case 'template':
return $this->previewTemplateMsg($data['msg']);
return Doo::translate($data['msg']['desc'] ?: '未知消息类型');
default:
$action = Doo::translate("未知的消息");
@ -617,55 +617,6 @@ class WebSocketDialogMsg extends AbstractModel
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

View File

@ -95,14 +95,20 @@ class BotReceiveMsgTask extends AbstractTask
if ($botUser->email === 'check-in@bot.system') {
$text = UserBot::checkinBotQuickMsg($command, $msg->userid);
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') {
$text = UserBot::anonBotQuickMsg($command);
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;
} else {
$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;
}
//
$array = Base::newTrim(explode(" ", "{$command} "));
$type = $array[0];
$data = [];
$notice = "";
$desc = "";
if (!$isManager && in_array($type, ['/list', '/newbot'])) {
return; // 这些操作仅支持【机器人管理】机器人
}
@ -143,20 +152,19 @@ class BotReceiveMsgTask extends AbstractTask
->orderByDesc('id')
->get();
if ($data->isEmpty()) {
$type = "notice";
$notice = "您没有创建机器人。";
$desc = "您没有创建机器人。";
}
break;
/**
* 详情
*/
case '/hello':
case '/info':
$botId = $isManager ? $array[1] : $botUser->userid;
$data = $this->botManagerOne($botId, $msg->userid);
if (!$data) {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -169,27 +177,27 @@ class BotReceiveMsgTask extends AbstractTask
->where('users.bot', 1)
->where('user_bots.userid', $msg->userid)
->count() >= 50) {
$type = "notice";
$notice = "超过最大创建数量。";
$desc = "超过最大创建数量。";
break;
}
if (strlen($array[1]) < 2 || strlen($array[1]) > 20) {
$type = "notice";
$notice = "机器人名称由2-20个字符组成。";
$desc = "机器人名称由2-20个字符组成。";
break;
}
$data = User::botGetOrCreate("user-" . Base::generatePassword(), [
'nickname' => $array[1]
], $msg->userid);
if (empty($data)) {
$type = "notice";
$notice = "创建失败。";
$desc = "创建失败。";
break;
}
$dialog = WebSocketDialog::checkUserDialog($data, $msg->userid);
if ($dialog) {
$text = "<p>您好,我是机器人:{$data->nickname}我的机器人ID是{$data->userid}</p><p>你可以发送 <u><b>/help</b></u> 查看我支持什么命令。</p>";
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $data->userid); // todo 未能在任务end事件来发送任务
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
'type' => '/hello',
'desc' => '创建成功。',
'data' => $data,
], $data->userid); // todo 未能在任务end事件来发送任务
}
break;
@ -200,8 +208,7 @@ class BotReceiveMsgTask extends AbstractTask
$botId = $isManager ? $array[1] : $botUser->userid;
$nameString = $isManager ? $array[2] : $array[1];
if (strlen($nameString) < 2 || strlen($nameString) > 20) {
$type = "notice";
$notice = "机器人名称由2-20个字符组成。";
$desc = "机器人名称由2-20个字符组成。";
break;
}
$data = $this->botManagerOne($botId, $msg->userid);
@ -211,8 +218,7 @@ class BotReceiveMsgTask extends AbstractTask
$data->pinyin = Base::cn2pinyin($nameString);
$data->save();
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -226,8 +232,7 @@ class BotReceiveMsgTask extends AbstractTask
if ($data) {
$data->deleteUser('delete bot');
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -240,8 +245,7 @@ class BotReceiveMsgTask extends AbstractTask
if ($data) {
User::generateToken($data);
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -256,8 +260,7 @@ class BotReceiveMsgTask extends AbstractTask
$data->password = Doo::md5s(Base::generatePassword(32), $data->encrypt);
$data->save();
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -278,8 +281,7 @@ class BotReceiveMsgTask extends AbstractTask
$data->clear_day = $userBot->clear_day;
$data->clear_at = $userBot->clear_at; // 这两个参数只是作为输出,所以不保存
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -291,8 +293,7 @@ class BotReceiveMsgTask extends AbstractTask
$webhookUrl = $isManager ? $array[2] : $array[1];
$data = $this->botManagerOne($botId, $msg->userid);
if (strlen($webhookUrl) > 255) {
$type = "notice";
$notice = "webhook地址最长仅支持255个字符。";
$desc = "webhook地址最长仅支持255个字符。";
} elseif ($data) {
$userBot = UserBot::whereBotId($botId)->whereUserid($msg->userid)->first();
if ($userBot) {
@ -303,8 +304,7 @@ class BotReceiveMsgTask extends AbstractTask
$data->webhook_url = $userBot->webhook_url ?: '-';
$data->webhook_num = $userBot->webhook_num; // 这两个参数只是作为输出,所以不保存
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
@ -325,8 +325,7 @@ class BotReceiveMsgTask extends AbstractTask
->take(20)
->get();
if ($list->isEmpty()) {
$type = "notice";
$notice = "没有搜索到相关会话。";
$desc = "没有搜索到相关会话。";
} else {
$list->transform(function (WebSocketDialog $item) use ($data) {
return $item->formatData($data->userid);
@ -334,19 +333,45 @@ class BotReceiveMsgTask extends AbstractTask
$data->list = $list; // 这个参数只是作为输出,所以不保存
}
} else {
$type = "notice";
$notice = "机器人不存在。";
$desc = "机器人不存在。";
}
break;
}
//
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
'type' => $type,
'data' => $data,
'notice' => $notice,
'manager' => $isManager,
'version' => Base::getVersion()
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
if ($desc) {
$msgData = [
'type' => 'desc',
'desc' => $desc,
];
} 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';
$userBot = null;
$extras = [];
$error = null;
$errorDesc = null;
switch ($botUser->email) {
// ChatGPT 机器人
case 'ai-openai@bot.system':
@ -377,10 +402,10 @@ class BotReceiveMsgTask extends AbstractTask
'chunk_size' => 7,
];
if (empty($extras['openai_key'])) {
$error = 'Robot disabled.';
$errorDesc = '机器人未启用。';
} 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.11).';
$errorDesc = '当前客户端版本低所需版本≥v0.29.11)。';
}
break;
// Claude 机器人
@ -393,10 +418,10 @@ class BotReceiveMsgTask extends AbstractTask
'server_url' => $serverUrl,
];
if (empty($extras['claude_token'])) {
$error = 'Robot disabled.';
$errorDesc = '机器人未启用。';
} 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.11).';
$errorDesc = '当前客户端版本低所需版本≥v0.29.11)。';
}
break;
// Wenxin 机器人
@ -410,10 +435,10 @@ class BotReceiveMsgTask extends AbstractTask
'server_url' => $serverUrl,
];
if (empty($extras['wenxin_key'])) {
$error = 'Robot disabled.';
$errorDesc = '机器人未启用。';
} 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).';
$errorDesc = '当前客户端版本低所需版本≥v0.29.12)。';
}
break;
// QianWen 机器人
@ -426,10 +451,10 @@ class BotReceiveMsgTask extends AbstractTask
'server_url' => $serverUrl,
];
if (empty($extras['qianwen_key'])) {
$error = 'Robot disabled.';
$errorDesc = '机器人未启用。';
} 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).';
$errorDesc = '当前客户端版本低所需版本≥v0.29.12)。';
}
break;
// Gemini 机器人
@ -444,10 +469,10 @@ class BotReceiveMsgTask extends AbstractTask
'server_url' => $serverUrl,
];
if (empty($extras['gemini_key'])) {
$error = 'Robot disabled.';
$errorDesc = '机器人未启用。';
} 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).';
$errorDesc = '当前客户端版本低所需版本≥v0.29.12)。';
}
break;
// 智谱清言 机器人
@ -460,10 +485,10 @@ class BotReceiveMsgTask extends AbstractTask
'server_url' => $serverUrl,
];
if (empty($extras['zhipu_key'])) {
$error = 'Robot disabled.';
$errorDesc = '机器人未启用。';
} 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).';
$errorDesc = '当前客户端版本低所需版本≥v0.29.12)。';
}
break;
// 其他机器人
@ -472,8 +497,11 @@ class BotReceiveMsgTask extends AbstractTask
$webhookUrl = $userBot?->webhook_url;
break;
}
if ($error) {
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $error], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
if ($errorDesc) {
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'template', [
'type' => 'desc',
'desc' => $errorDesc,
], $botUser->userid, false, false, true); // todo 未能在任务end事件来发送任务
return;
}
if (!preg_match("/^https*:\/\//", $webhookUrl)) {
@ -498,13 +526,13 @@ class BotReceiveMsgTask extends AbstractTask
$userBot->webhook_num++;
$userBot->save();
}
if($res['data'] && $data = json_decode($res['data'])){
if($data['code'] != 200 && $data['message']){
if ($res['data'] && $data = json_decode($res['data'])) {
if ($data['code'] != 200 && $data['message']) {
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $res['data']['message']], $botUser->userid, false, false, true);
}
}
} catch (\Throwable $th) {
//throw $th;
info($th->getMessage());
}
}

View File

@ -47,7 +47,7 @@ class UnclaimedTaskRemindTask extends AbstractTask
Project::whereNull('deleted_at')->whereNull('archived_at')->chunk(100, function ($projects) {
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) {
$query->on('project_tasks.id', '=', 'project_task_users.task_id');
})
@ -68,12 +68,15 @@ class UnclaimedTaskRemindTask extends AbstractTask
$project->syncDialogUser();
}
//
$taskHtml = '<span style="line-height: 26px;">任务待领取</span> <br/>';
foreach ($projectTasks as $projectTask) {
$taskHtml .= "<span class=\"mention task\" style=\"line-height: 26px;\" data-id=\"{$projectTask->id}\">#{$projectTask->name}</span> <br/>";
}
WebSocketDialogMsg::sendMsg(null, $project->dialog_id, 'text', [
'text' => $taskHtml
WebSocketDialogMsg::sendMsg(null, $project->dialog_id, 'template', [
'type' => 'task_unclaimed',
'desc' => '任务待领取',
'list' => $projectTasks->map(function ($item) {
return [
'id' => $item->id,
'name' => $item->name,
];
}),
], $botUser->userid);
}
}

View File

@ -431,9 +431,8 @@ IT资讯
36氪
60s读世界
Api接口文档
我的机器人
Api接口文档
API接口文档
帮助指令
使用说明
隐私说明
@ -531,3 +530,36 @@ OKR提醒
上班时间到了,你还没有打卡哦~
快到上班时间了,别忘了打卡哦~
任务待领取
非常抱歉,我不是你的机器人,无法完成你的指令。
您没有创建机器人。
机器人不存在。
超过最大创建数量。
机器人名称由2-20个字符组成。
创建失败。
创建成功。
webhook地址最长仅支持255个字符。
没有搜索到相关会话。
您好
帮助指令
我的机器人
机器人信息
新建机器人
设置名称
删除机器人
机器人Token
更新Token
设置Webhook
设置保留消息时间
对话列表
API接口文档
不支持的指令
机器人未启用。
当前客户端版本低(所需版本≥(*))。
审批结果
审批评论通知
审批通知
待你审批
未知的消息
未知消息类型

View File

@ -1616,3 +1616,36 @@ License Key
未知错误
网络异常,请重试。
请求失败,请重试。
任务待领取
非常抱歉,我不是你的机器人,无法完成你的指令。
您没有创建机器人。
机器人不存在。
超过最大创建数量。
机器人名称由2-20个字符组成。
创建失败。
创建成功。
webhook地址最长仅支持255个字符。
没有搜索到相关会话。
您好
帮助指令
我的机器人
机器人信息
新建机器人
设置名称
删除机器人
机器人Token
更新Token
设置Webhook
设置保留消息时间
对话列表
API接口文档
不支持的指令
机器人未启用。
当前客户端版本低(所需版本≥(*))。
审批结果
审批评论通知
审批通知
待你审批
未知的消息
未知消息类型

View File

@ -16432,9 +16432,9 @@
"ru": "60 человек читают мир"
},
{
"key": "Api接口文档",
"key": "API接口文档",
"zh": "",
"zh-CHT": "Api接口文檔",
"zh-CHT": "API接口文檔",
"en": "Api interface documentation",
"ko": "Api 인터페이스 문서",
"ja": "Apiインタフェース文書です",
@ -22742,4 +22742,4 @@
"id": "Sudah hampir waktunya bekerja, jangan lupa untuk meninju jam oh ~",
"ru": "Пора на работу, не забудь отметиться"
}
]
]

View File

@ -411,7 +411,7 @@ import {MarkdownPreview} from "../store/markdown";
case 'notice':
return data.msg.notice
case 'template':
return $A.tempMsgSimpleDesc(data.msg)
return $A.L(data.msg.desc || '未知消息类型')
default:
return `[${$A.L('未知的消息')}]`
}
@ -440,54 +440,6 @@ import {MarkdownPreview} from "../store/markdown";
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

View File

@ -51,7 +51,6 @@
@on-view-text="onViewText"
@on-view-file="onViewFile"
@on-down-file="onDownFile"
@on-click-template="onClickTemplate"
@on-reply-list="onReplyList"
@on-error="onError"
@on-emoji="onEmoji"
@ -253,10 +252,6 @@ export default {
this.dispatch("on-down-file", data)
},
onClickTemplate(e) {
this.dispatch("on-click-template", e)
},
onReplyList(data) {
this.dispatch("on-reply-list", data)
},

View File

@ -38,7 +38,7 @@
<!--投票-->
<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"/>
<!--未知-->
@ -598,10 +598,6 @@ export default {
this.$set(msgData.msg, '_loadIng', 0)
});
},
clickTemplate(e) {
this.$emit("on-click-template", e)
},
}
}
</script>

View File

@ -5,7 +5,7 @@
<p><b>发送文本消息</b></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>--form 'dialog_id="<span class="mark-color">{对话ID}</span>"' \</p>
<p>--form 'text="<span class="mark-color">{消息内容}</span>"'</p>

View File

@ -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>

View File

@ -16,7 +16,7 @@
<p><span class="mark-color">/setname{{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">/webhook{{IDLabel}} [url]</span> - 设置消息Webhook详情请看 <u>Api接口文档</u></p>
<p><span class="mark-color">/webhook{{IDLabel}} [url]</span> - 设置消息Webhook详情请看 <u>API接口文档</u></p>
<p>&nbsp;</p>
<p><b>机器人设置</b></p>
@ -28,7 +28,7 @@
<p><span class="mark-color">/dialog{{IDLabel}} [搜索关键词]</span> - 查看会话ID</p>
<p>&nbsp;</p>
<p><b>Api接口文档</b></p>
<p><b>API接口文档</b></p>
<p><span class="mark-color">/api</span> - 查看接口列表</p>
</div>
</template>

View File

@ -1,6 +1,6 @@
<template>
<div>
{{msg.notice}}
{{$L(msg.desc)}}
</div>
</template>
<script lang="ts">

View File

@ -1,10 +1,11 @@
<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"/>
</div>
</template>
<script lang="ts">
import BotHello from "./bot-hello.vue";
import BotHelp from "./bot-help.vue";
import BotList from "./bot-list.vue";
import BotInfo from "./bot-info.vue";
@ -17,11 +18,15 @@ import BotWebhook from "./bot-webhook.vue";
import BotClearday from "./bot-clearday.vue";
import BotDialog from "./bot-dialog.vue";
import BotApi from "./bot-api.vue";
import Notice from "./notice.vue";
import ApproveReviewer from "./approve-reviewer.vue";
import ApproveNotifier from "./approve-notifier.vue";
import ApproveCommentNotifier from "./approve-comment-notifier.vue";
import ApproveSubmitter from "./approve-submitter.vue";
import TaskUnclaimed from "./task-unclaimed.vue";
import Desc from "./desc.vue";
import Other from "./other.vue";
export default {
@ -34,6 +39,8 @@ export default {
computed: {
currentTemplate() {
switch (this.msg.type) {
case '/hello':
return BotHello;
case '/help':
return BotHelp;
case '/list':
@ -68,16 +75,19 @@ export default {
case 'approve_submitter':
return ApproveSubmitter;
case 'notice':
return Notice;
case 'task_unclaimed':
return TaskUnclaimed;
case 'desc':
return Desc;
default:
return Other;
}
},
},
methods: {
onClick(e) {
this.$emit('clickTemplate', e);
viewText(e) {
this.$emit('viewText', e);
},
},
}

View File

@ -1,6 +1,6 @@
<template>
<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 v-else>
未知消息类型

View File

@ -0,0 +1,23 @@
<template>
<div>
<p>任务待领取</p>
<p>&nbsp;</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>

View File

@ -204,7 +204,6 @@
@on-view-text="onViewText"
@on-view-file="onViewFile"
@on-down-file="onDownFile"
@on-click-template="onClickTemplate"
@on-reply-list="onReplyList"
@on-error="onError"
@on-emoji="onEmoji"
@ -3122,8 +3121,17 @@ export default {
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) {
@ -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) {
if (this.operateVisible) {
return

View File

@ -250,15 +250,6 @@ body.dark-mode-reverse {
a {
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 {

View File

@ -915,40 +915,6 @@
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 {
color: #ffffff;
.warning-color {
color: $flow-status-start-color;
}
.mark-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 {
@ -1680,19 +1683,6 @@
.dialog-content {
.content-text {
color: #ffffff;
> pre {
.mention {
color: $primary-title-color;
&.me {
font-size: inherit;
font-weight: inherit;
padding: inherit;
background-color: inherit;
}
}
}
}
.content-record {
@ -1757,6 +1747,17 @@
border-color: #f3f3f3;
}
}
.mention {
color: $primary-title-color;
&.me {
font-size: inherit;
font-weight: inherit;
padding: inherit;
background-color: inherit;
}
}
}
.dialog-emoji {