140 lines
6.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<DialogMarkdown :text="content"/>
</template>
<script>
import DialogMarkdown from "../../DialogMarkdown.vue";
export default {
components: {DialogMarkdown},
props: {
msg: Object,
},
data() {
return {};
},
computed: {
content() {
const sessionDesc = !/^(ai-|user-session-)/.test(this.msg.email) ? " <span style='color:#999;padding-left:4px;'>({{该机器人不支持}})</span>" : "";
return [
"## {{API 使用说明}}",
"",
"### 1. {{发送文本消息}}",
"",
"{{开发者可以通过此接口调用机器人向指定对话发送文本消息。}}",
"",
"#### {{接口信息}}",
"",
"| {{属性}} | {{结果}} |",
"|------|------|",
"| **{{请求方式}}** | POST |",
"| **{{接口地址}}** | `" + $A.apiUrl('dialog/msg/sendtext') + "` |",
"| **{{说明}}** | {{通过机器人向指定对话发送文本消息}} |",
"",
"#### {{请求头}}",
"",
"| {{参数名}} | {{值}} | {{必填}} |",
"|--------|-----|------|",
"| `version` | `" + this.msg.version + "` | √ |",
"| `token` | {{机器人Token}} | √ |",
"",
"#### {{请求参数}}",
"",
"| {{参数名}} | {{说明}} | {{类型}} | {{必填}} | {{示例值}} |",
"|--------|------|------|------|--------|",
"| `dialog_id` | {{对话ID}} | string | √ | |",
"| `text` | {{消息内容}} | string | √ | |",
"| `text_type` | {{文本类型}} | string | | {{html 或 md}} |",
"| `key` | {{搜索词}} | string | | {{留空自动生成}} |",
"| `silence` | {{静默模式}} | string | | {{yes 或 no}} |",
"| `reply_id` | {{回复指定消息ID}} | string | | |",
"",
"### 2. {{Webhook 消息推送}}",
"",
"{{机器人收到消息后会自动POST推送到配置的Webhook地址请求超时为10秒。}}",
"",
"#### {{推送参数}}",
"",
"| {{参数名}} | {{说明}} | {{类型}} |",
"|--------|------|------|",
"| `text` | {{消息文本内容}} | string |",
"| `reply_text` | {{回复/引用的消息文本}} | string |",
"| `token` | {{机器人Token}} | string |",
"| `session_id` | {{会话ID}}" + sessionDesc + " | string |",
"| `dialog_id` | {{对话ID}} | string |",
"| `dialog_type` | {{对话类型}} | string |",
"| `msg_id` | {{消息ID}} | string |",
"| `msg_uid` | {{消息发送人ID}} | string |",
"| `msg_user` | {{消息发送人信息}} | object |",
"| `mention` | {{是否被@到}} | boolean |",
"| `bot_uid` | {{机器人ID}} | string |",
"| `version` | {{系统版本}} | string |",
"### 3. {{打开会话 消息推送}}",
"",
"{{打开机器人会话后会自动POST推送到配置的Webhook地址请求超时为30秒。}}",
"",
"#### {{推送参数}}",
"",
"| {{参数名}} | {{说明}} | {{类型}} |",
"|--------|------|------|",
"| `event` | {{推送事件}} | string |",
"| `timestamp` | {{推送时间戳}} | string |",
"| `dialog_id` | {{对话ID}} | string |",
"| `dialog_type` | {{对话类型}} | string |",
"| `bot_uid` | {{机器人ID}} | string |",
"| `owner_uid` | {{机器人所属用户ID}} | string |",
"| `user` | {{机器人所属用户信息}} | object |",
"| `user.userid` | {{用户ID}} | string |",
"| `user.email` | {{用户邮箱}} | string |",
"| `user.nickname` | {{用户昵称}} | string |",
"### 4. {{成员加入 消息推送}}",
"",
"{{成员加入群组后会自动POST推送到配置的Webhook地址请求超时为30秒。}}",
"",
"#### {{推送参数}}",
"",
"| {{参数名}} | {{说明}} | {{类型}} |",
"|--------|------|------|",
"| `event` | {{推送事件}} | string |",
"| `timestamp` | {{推送时间戳}} | string |",
"| `dialog_id` | {{对话ID}} | string |",
"| `dialog_type` | {{对话类型}} | string |",
"| `bot_uid` | {{机器人ID}} | string |",
"| `owner_uid` | {{机器人所属用户ID}} | string |",
"| `user` | {{机器人所属用户信息}} | object |",
"| `user.userid` | {{用户ID}} | string |",
"| `user.email` | {{用户邮箱}} | string |",
"| `user.nickname` | {{用户昵称}} | string |",
"### 5. {{成员退出 消息推送}}",
"",
"{{成员退出群组后会自动POST推送到配置的Webhook地址请求超时为30秒。}}",
"",
"#### {{推送参数}}",
"",
"| {{参数名}} | {{说明}} | {{类型}} |",
"|--------|------|------|",
"| `event` | {{推送事件}} | string |",
"| `timestamp` | {{推送时间戳}} | string |",
"| `dialog_id` | {{对话ID}} | string |",
"| `dialog_type` | {{对话类型}} | string |",
"| `dialog_name` | {{对话名称}} | string |",
"| `group_type` | {{群组类型}} | string |",
"| `bot_uid` | {{机器人ID}} | string |",
"| `owner_uid` | {{机器人所属用户ID}} | string |",
"| `action` | {{动作}} | string |",
"| `actor` | {{操作人信息}} | object |",
"| `actor.userid` | {{用户ID}} | string |",
"| `actor.email` | {{用户邮箱}} | string |",
"| `actor.nickname` | {{用户昵称}} | string |",
"| `actor.is_bot` | {{是否机器人}} | boolean |",
"| `members` | {{成员信息}} | array |",
"| `members.userid` | {{用户ID}} | string |",
"| `members.email` | {{用户邮箱}} | string |",
"| `members.nickname` | {{用户昵称}} | string |",
"| `members.is_bot` | {{是否机器人}} | boolean |",
].map(item => item.replace(/\{\{([^}]+)\}\}/g, (_, v1) => this.$L(v1))).join("\n");
},
},
methods: {},
}
</script>