Skip to content

Commit

Permalink
feat: 插件收录
Browse files Browse the repository at this point in the history
  • Loading branch information
Lain. committed Apr 26, 2024
1 parent 266c0c3 commit bac575a
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 59 deletions.
50 changes: 24 additions & 26 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,33 @@ export default defineConfig({
themeConfig: {
siteTitle: '主页',
nav: [
{ text: '主页', link: '/' },
{ text: '快速开始', link: '/start' },
{ text: '开发文档', link: '/develop/index' },
{ text: 'elements', link: '/develop/elements' }
],
sidebar: [
{
text: '目录',
items: [
{ text: '主页', link: '/' },
{ text: '快速开始', link: '/start' }
]
},
{
text: '事件',
items: [
{ text: '消息事件', link: '/event/message' }
]
},
{
text: '插件开发',
items: [
{ text: 'elements', link: '/develop/elements' },
{ text: '#karin', link: '/develop/karin' },
{ text: 'YamlEditor', link: '/develop/YamlEditor' },
{ text: '插件编写', link: '/develop/plugin' },
]
}
{ text: 'elements', link: '/develop/elements' },
{ text: '插件索引', link: '/plugins/index' },
],
sidebar: {
'/event/': [
{
text: '事件',
items: [
{ text: '目录', link: '/event/index' },
{ text: '消息事件', link: '/event/message' }
],
}
],
'/develop/': [
{
text: '插件开发',
items: [
{ text: 'elements', link: '/develop/elements' },
{ text: '#karin', link: '/develop/karin' },
{ text: 'YamlEditor', link: '/develop/YamlEditor' },
{ text: '插件编写', link: '/develop/plugin' },
]
}
]
},
socialLinks: [
{ icon: 'github', link: 'https://github.com/KarinJS/Karin' }
],
Expand Down
39 changes: 28 additions & 11 deletions docs/develop/elements.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## elements
# elements

本文档介绍了 Krita 的消息元素结构和 `segment` 模块的使用方法。

Expand All @@ -7,6 +7,7 @@
:::

## 导入

::: tip 温馨提示
以下所有的示例都假设你已经导入了 `segment` 模块。
:::
Expand All @@ -26,17 +27,20 @@ karin对于多媒体资源的标准化处理,遵循以下规则:

::: tip 注意
对于`file://`格式,请开发者注意以下几点:

- 请确保用户的协议端和karin运行环境一致,否则可能导致文件读取失败
- 对于Linux系统,由于绝对路径前方有`/`,格式为`file:///root/...`,请注意区分`///``//`
:::

## 文本 text

```js
const text = segment.text('Hello, world!')
console.log(text)
```

输出:

```js
{
type: 'text',
Expand All @@ -56,14 +60,14 @@ console.log(face)
```

输出:

```js
{
type: 'face',
id: 1
}
```


## 图片 image

::: tip 温馨提示
Expand All @@ -79,6 +83,7 @@ console.log(image)
```

输出:

```js
{ // 对于网络图片,要求传入的url必须为https://或http://开头
type: 'image',
Expand Down Expand Up @@ -110,25 +115,27 @@ console.log(record)
```

输出:

```js
{
type:'record',
file: 'https://example.com/record.mp3'
}
```


## 视频 video

::: tip 温馨提示
遵循 [多媒体资源标准](#多媒体资源标准)
:::
:::

```js
const video = segment.video('https://example.com/video.mp4')
console.log(video)
```

输出:

```js
{
type: 'video',
Expand All @@ -148,6 +155,7 @@ console.log(at)
```

输出:

```js
{
type: 'at',
Expand All @@ -166,6 +174,7 @@ console.log(poke)
```

输出:

```js
{
type: 'poke',
Expand All @@ -183,6 +192,7 @@ console.log(share)
```

输出:

```js
{
type:'share',
Expand All @@ -200,8 +210,8 @@ const contact = segment.contact('qq', '12345')
console.log(contact)
```


输出:

```js
{
type: 'contact',
Expand All @@ -217,8 +227,8 @@ const location = segment.location('121.527328', '31.21515', '上海市浦东新
console.log(location)
```


输出:

```js
{
type: 'location',
Expand All @@ -231,14 +241,13 @@ console.log(location)

## 音乐分享 music


```js
const music = segment.music('qq', '12345')
console.log(music)
```


输出:

```js
{
type:'music',
Expand All @@ -254,8 +263,8 @@ const customMusic = segment.customMusic('https://example.com/music.mp3', 'https:
console.log(customMusic)
```


输出:

```js
{
type: 'customMusic',
Expand All @@ -275,6 +284,7 @@ console.log(reply)
```

输出:

```js
{
type:'reply',
Expand All @@ -290,6 +300,7 @@ console.log(forward)
```

输出:

```js
{
type: 'forward',
Expand All @@ -305,6 +316,7 @@ console.log(node)
```

输出:

```js
{
type: 'node',
Expand All @@ -327,6 +339,7 @@ console.log(xml)
```

输出:

```js
{
type: 'xml',
Expand All @@ -343,6 +356,7 @@ console.log(json)
```

输出:

```js
{
type: 'json',
Expand All @@ -367,8 +381,8 @@ const markdown = segment.markdown({
console.log(markdown)
```


输出:

```js
// 原生markdown内容
{
Expand Down Expand Up @@ -550,6 +564,7 @@ rows和button的键入值一致,且比较复杂,请查看最下方的构建
:::

### 跳转按钮

```js:line-numbers {1}
// 快速构建
segment.rows({ link: 'https://example.com' })
Expand All @@ -569,6 +584,7 @@ segment.rows({
```

### 回调按钮

```js:line-numbers {1}
// 快速构建
segment.rows({ type: 1, text: '回调按钮'})
Expand All @@ -589,6 +605,7 @@ segment.rows({
```

### 指令按钮

```js:line-numbers {1}
// 快速构建
segment.rows({ text: '指令按钮' })
Expand All @@ -606,4 +623,4 @@ segment.rows({
list: ['用户ID1', '用户ID2'], // 设置后,只有这些用户可以点击,与admin互斥
role: ['用户ID1', '用户ID2'], // 设置后,只有这些用户可以点击,与admin互斥 (仅频道可用)
tips: '指令提示' // 客户端不支持本 action 的时候,弹出的 toast 文案
})
})
12 changes: 7 additions & 5 deletions docs/develop/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ app.reg({
export const hello = app.plugin(app)

```

3. 保存,对机器人输入`你好`,机器人会回复`hello`

以上,是一个最基本的插件构建方法。

### 方法2

```js
import { plugin } from '#Karin'

Expand Down Expand Up @@ -111,9 +113,11 @@ export class hello extends plugin {
```

## 完整参数
>
> 以下是一个完整的插件编写示例。
### 方法1

```js
import { App } from '#Karin'

Expand Down Expand Up @@ -148,6 +152,7 @@ export const hello = app.plugin(app)
```

### 方法2

```js
import { plugin } from '#Karin'

Expand Down Expand Up @@ -195,14 +200,12 @@ export class hello extends plugin {

>高级监听事件:

| | 结构 | 参考 | 说明 |
| -------- | -------------------------------- | -------------------- | ------------ |
| 一级事件 | `post_type` | `message` | 所有消息事件 |
| 二级事件 | `post_type.notice_type` | `message.group` | 群消息事件 |
| 三级事件 | `post_type.notice_type.sub_type` | `notice.notify.poke` | 群内戳一戳 |


## 消息匹配规则

| 参数 | 必须 | 类型 | 说明 |
Expand All @@ -212,7 +215,6 @@ export class hello extends plugin {
| log | | boolean | 是否显示操作日志 |
| permission | | string | 权限 master,owner,admin,all |


> 一些正则...
| 正则 | 说明 | | 正则 | 说明 |
Expand All @@ -227,11 +229,11 @@ export class hello extends plugin {
| [^] | 非字符集 | | \B | 非单词边界 |
| () | 分组 | | \| ||


## 快速回复

| 参数 | 必须 | 类型 | 说明 |
| --------- | ---- | ------- | ---------------------------------------------- |
| at | | boolean | 是否@回复发送者消息 |
| recallMsg | | number | 单位秒,设置后,将在指定时间撤回本次回复的消息 |
| reply | | boolean | 是否引用回复发送者消息 |
| button | | boolean | 是否加入按钮,暂未实现 |
| button | | boolean | 是否加入按钮,暂未实现 |
4 changes: 2 additions & 2 deletions docs/event/message.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:::

### 标准属性对象

```js
const message = {
self_id: 'string', // 机器人的ID,默认为uin
Expand Down Expand Up @@ -79,7 +80,6 @@ e.reply('Hello', { retry_count: 1 }) // 重试次数
e.reply('Hello', { at: true, reply: true, recallMsg: 10, button: false, retry_count: 1 })
```


| 参数 | 类型 | 说明 |
| ------------------- | ------- | -------------------------------- |
| message | string | 回复消息内容 |
Expand All @@ -88,4 +88,4 @@ e.reply('Hello', { at: true, reply: true, recallMsg: 10, button: false, retry_co
| options.reply | boolean | 是否引用回复消息本身 |
| options.recallMsg | number | 发送成功后,撤回消息时间,单位秒 |
| options.button | boolean | 暂未实现 |
| options.retry_count | number | 发送失败后,重试次数 |
| options.retry_count | number | 发送失败后,重试次数 |
Loading

0 comments on commit bac575a

Please sign in to comment.