Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/develop/nodesdk/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
{ title: '成员对象(Member)', path: 'model/member' },
{ title: '频道身份组对象(Role)', path: 'model/role' },
{ title: '消息对象(Message)', path: 'model/message' },
{title: '消息按钮对象(InlineKeyboard)', path: 'model/inline_keyboard'},
{ title: '私信对象(DMS)', path: 'model/dms' },
{ title: '公告对象(Announce)', path: 'model/announce' },
{ title: '精华消息对象(PinsMessage)', path: 'model/pins_message.md' },
Expand Down Expand Up @@ -104,6 +105,7 @@ module.exports = {
'message/post_ark_messages',
'message/message_format',
'message/post_reference_messages',
'message/post_keyboard_message.md',
],
},
{
Expand Down
93 changes: 93 additions & 0 deletions docs/develop/nodesdk/message/post_keyboard_message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 发送带有按钮的消息

## 效果

![keyboard](../../../.vuepress/public/images/node-sdk/keyboard.png)

## 功能描述

通过在 `MessageToCreate` 中指定 `keyboard` 字段发送带按钮的消息,支持 `keyboard 模版` 和 `自定义 keyboard` 两种请求格式。

- 要求操作人在该子频道具有`发送消息`和 对应`消息按钮组件` 的权限。
- 请求参数 `keyboard 模版` 和 `自定义 keyboard` 只能单一传值。
- `keyboard 模版`
- 调用前需要先申请消息按钮组件模板,这一步会得到一个模板 id,在请求时填在 `keyboard` 字段上。
- 申请消息按钮组件模板需要提供响应的 json,具体格式参考 [InlineKeyboard](../model/inline_keyboard.md#InlineKeyboard)。
- 仅 markdown 消息支持消息按钮。

## 使用示例

### 1:使用 keyboard 模版

```ts
async function demo() {
let { data } = await client.messageApi.postMessage(channelID, {
markdown: {
template_id: 1,
params: [
{
key: 'title',
value: ['标题'],
},
],
},
msg_id: 'xxxxxx',
keyboard: {
id: '123',
},
});
}
```

### 2:使用自定义 keyboard

```ts
async function demo() {
let { data } = await client.messageApi.postMessage(channelID, {
markdown: {
template_id: 1,
params: [
{
key: 'title',
value: ['标题'],
},
],
},
msg_id: 'xxxxxx',
keyboard: {
content: {
rows: [
{
buttons: [
{
id: '1',
render_data: {
label: 'AtBot-按钮1',
visited_label: '点击后按钮1上文字',
},
action: {
type: 2,
permission: {
type: 2,
specify_role_ids: ['1', '2', '3'],
},
click_limit: 10,
unsupport_tips: '编辑-兼容文本',
data: '/搜索',
at_bot_show_channel_list: true,
},
},
],
},
],
bot_appid: 123123123,
},
},
});
}
```


## 返回说明

成功返回 [Message](../model/message.md#message) 对象
70 changes: 70 additions & 0 deletions docs/develop/nodesdk/model/inline_keyboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 消息按钮组件(InlineKeyboard)<Badge text="v1.0.0" />

### InlineKeyboard

| 字段名 | 类型 | 描述 |
|-----------|-----------------------------------------------------|---------------------------|
| rows | [InlineKeyboardRow](#inlinekeyboardrow) 消息按钮组件行对象数组 | 数组的一项代表消息按钮组件的一行,最多含有 5 行 |

### InlineKeyboardRow

| 字段名 | 类型 | 描述 |
|---------|--------------------------|--------------------------------------------------|
| buttons | [Button](#button) 按钮对象数组 | 数组的一项代表一个按钮,每个 InlineKeyboardRow 最多含有 5 个 Button |

### Button

| 字段名 | 类型 | 描述 |
|-------------|------------------------------------|--------------|
| id | string | 按钮 id |
| render_data | [RenderData](#renderdata) 按纽渲染展示对象 | 用于设定按钮的显示效果 |
| action | [Action](#action) 该按纽操作相关字段 | 用于设定按钮点击后的操作 |

### RenderData

| 字段名 | 类型 | 描述 |
|---------------|--------|-------------------------------------|
| label | string | 按纽上的文字 |
| visited_label | string | 点击后按纽上文字 |
| style | int | 按钮样式,参考 [RenderStyle](#renderstyle) |

### RenderStyle

| 字段名 | 类型 | 描述 |
|-----|-----|------|
| 0 | int | 灰色线框 |
| 1 | int | 蓝色线框 |

### Action

| 字段名 | 类型 | 描述 |
| ------------------------ | ------------------------------- | ---------------------------------------------- |
| type | int | 操作类型,参考 [ActionType](#actiontype) |
| permission | [Permission](#permission) 对象 | 用于设定操作按钮所需的权限 |
| click_limit | int | 可点击的次数, 默认不限 |
| data | string | 操作相关数据 |
| at_bot_show_channel_list | bool | false:不弹出子频道选择器 true:弹出子频道选择器 |

### ActionType
| 值 | 描述 |
| --- | ------------------------------------------------------------------------------------------- |
| 0 | http 或 小程序 客户端识别 schem, data字段为链接 |
| 1 | 回调后台接口, data 传给后台 |
| 2 | at机器人, 根据 at_bot_show_channel_list 决定在当前频道或用户选择频道,自动在输入框 @bot data |

### Permission

| 字段名 | 类型 | 描述 |
| ---------------- | ----------- | ------------------------------------------------ |
| type | int | 权限类型,参考 [PermissionType](#permissiontype) |
| specify_role_ids | string 数组 | 有权限的身份组id的列表 |
| specify_user_ids | string 数组 | 有权限的用户id的列表 |

### PermissionType

| 值 | 描述 |
| --- | ---------------- |
| 0 | 指定用户可操作 |
| 1 | 仅管理者可操作 |
| 2 | 所有人可操作 |
| 3 | 指定身份组可操作 |