Skip to content

Commit

Permalink
fix: 乏了 不写了
Browse files Browse the repository at this point in the history
  • Loading branch information
shijinn520 committed Aug 24, 2024
1 parent a4c81d3 commit 7d974f1
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 23 deletions.
137 changes: 136 additions & 1 deletion docs/api/api.md
Original file line number Diff line number Diff line change
@@ -1 +1,136 @@
# 正在编写中,咕咕咕~
# 标准api

[[toc]]

## 先决条件

> 下方展示均为 `api` `参数` `返回值` 的展示,具体使用方法请参考下方的示例代码
被动事件调用: `e.bot`

```JavaScript{3}
import karin from 'node-karin'
export const test = karin.command(/^test$/, async (e) => {
const data = e.bot.<方法名>(参数1, 参数2, ...) // [!code warning]
console.log(data)
return true
})
```

主动调用: `karin.getBot`

```JavaScript{5}
import karin from 'node-karin'
const self_id = '1234567890'
const Bot = karin.getBot(self_id)
const data = Bot.<方法名>(参数1, 参数2, ...) // [!code warning]
console.log(data)
```

## logger

> 方法名: `logger`
> 描述: `打印带有Bot前缀带有颜色日志`
> 参数: `level` `...args`
> 返回值: `void`
| 参数名称 | 类型 | 参数要求 | 备注 |
| :-------: | :----: | :---------------------------------------------------------------------: | :------: |
| `level` | string | `all` `trace` `debug` `mark` `info` `mark` `warn` `error` `fatal` `off` | 日志等级 |
| `...args` | any[] | 日志内容 | 日志内容 |

使用示例:

::: code-group

```JavaScript [被动事件调用]
e.bot.logger('info', '这是一个info日志')
```

```JavaScript [主动事件调用]
Bot.logger('info', '这是一个info日志')
```

```bash [响应]
# 这里其实每个日志等级都有对应的颜色,但是由于文档的限制,无法展示
[Karin][08:22:50.292][INFO] [Bot:1234567890] 这是一个info日志
```

:::

## 获取头像url

> 方法名: `getAvatarUrl`
> 描述: `获取头像url,Bot自身也是此参数`
> 参数: `user_id` `size`
> 返回值: `string`
| 参数名称 | 类型 | 参数要求 | 备注 |
| :------: | :----: | :------------------: | :------: |
| user_id | string | --- | 用户ID |
| size | number | `0` `40` `100` `140` | 头像大小 |

::: code-group

```JavaScript [被动事件调用]
e.bot.getAvatarUrl(e.user_id)
```

```JavaScript [主动事件调用]
Bot.getAvatarUrl(user_id)
```

```bash [响应]
https://q.qlogo.cn/headimg_dl?dst_uin=1234567890&spec=100
```

:::

## 获取群头像

> 方法名: `getGroupAvatarUrl`
> 描述: `获取群头像url`
> 参数: `group_id` `size` `history`
> 返回值: `string`
| 参数名称 | 类型 | 参数要求 | 备注 |
| :------: | :----: | :------------------: | :-------------------------------------------: |
| group_id | string | --- | 群号 |
| size | number | `0` `40` `100` `140` | 头像大小 |
| history | number | `1,2,3...` | 历史头像<Badge type="warning" text="可选 " /> |

::: code-group

```JavaScript [被动事件调用]
e.bot.getGroupAvatarUrl(e.group_id)
// or
e.bot.getGroupAvatarUrl(e.group_id, 100)
```

```JavaScript [主动事件调用]
Bot.getGroupAvatarUrl(group_id)
// or
Bot.getGroupAvatarUrl(group_id, 100)
```

```bash [响应]
https://p.qlogo.cn/gh/1234567890/1234567890/100
```

:::

<!--
/**
* 获取群头像url 请使用`getGroupAvatarUrl`
* @param group_id - 群号
* @param size - 头像大小,默认`0`
* @param history - 历史头像记录,默认`0`,若要获取历史群头像则填写1,2,3...
* @returns 头像的url地址
* @deprecated
*/
getGroupAvatar (group_id: string, size?: 0 | 40 | 100 | 140, history?: number): string
-->
18 changes: 11 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ hero:


features:
- title: 轻量级
details: 采用精简的代码设计,确保框架易于维护和扩展。框架无任何内置插件包,开发者可以根据自己的需求自由选择插件。
- title: 易于上手
details: 基于JavaScript,开发者可以快速学习并使用现有的编程知识来创建功能丰富的插件。
- title: 详尽文档
details: 提供全面的文档支持,帮助开发者轻松掌握框架的使用和插件开发。
- title: 轻量 · 高效
details: 极简设计,运行速度快,资源占用低,专为高性能Bot开发而生。

- title: 快速上手 · 全面支持
details: 提供详尽的文档和丰富的示例,帮助开发者迅速上手并深度掌握框架功能。

- title: TypeScript · 强类型支持
details: 基于TypeScript构建,提供完整的类型注释,确保代码可靠性和可维护性。


---

<HomeUnderline />
<confetti />
<confetti />
3 changes: 1 addition & 2 deletions docs/plugins/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import { axios } from 'node-karin/modules.js'

export const image = karin.command(/^#动漫壁纸$/, async (e) => {
// 来自: https://blog.jixiaob.cn/?post=93
const { data } = await axios.get('https://t.alcy.cc/mp')
await e.reply(segment.image(data.url))
await e.reply(segment.image('https://t.alcy.cc/mp'))
return true
})

Expand Down
10 changes: 6 additions & 4 deletions docs/plugins/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 命名规范

### 插件包
### Git插件包

> **这里必须遵守,否则将无法被karin识别启用**
Expand All @@ -14,7 +14,8 @@

### 单个`js`

> 这里是推荐规范,不强制要求
> 这里是推荐规范,不强制要求
> 一般情况下 不建议另外再创建一个同样功能的 `karin-plugin-example` 文件夹。
- 统一存放在 `karin` 提供的 `karin-plugin-example`
- 使用英文进行命名,无固定前缀要求
Expand Down Expand Up @@ -86,8 +87,9 @@ kritor-plugin-hello
> 无需一定遵守,但是推荐遵守
- 对于配置文件,由于使用 `git` 进行管理升级,所以一般会有两种配置文件:`默认配置``用户配置`
- `默认配置` :要求统一存放在 `config/defSet/` 下,由开发者进行维护修改,此处禁止用户编辑修改
- `用户配置` :要求统一存放在 `config/config/` 下,由用户进行编辑修改。
- `Git默认配置` :要求统一存放在插件自身的 `karin/plugin/<plugin_name>config/` 下,由开发者进行维护修改,此处禁止用户编辑修改。
- `Npm默认配置` :要求统一存放在插件自身的 `karin/node_modules/<plugin_name>config/` 下,由开发者进行维护修改,此处禁止用户编辑修改。
- `用户配置` :要求统一存放在 `karin/config/plugin/<plugin_name>` 下,由用户进行编辑修改。
- 如无特殊需求,请不要在 `config` 文件夹下创建其他文件夹

> 对于这里,建议使用 [**`karin-plugin-template`**](#结构规范) 作为模板,进行开发
Expand Down
24 changes: 15 additions & 9 deletions docs/start/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- `windows`用户如下载缓慢,可使用[腾讯软件管家][腾讯软件管家]进行加速下载。
- 还是一样,`git`也是一个可选项,所有插件包括`Karin`本身都可以直接下载压缩包进行安装。

- 目前`Karin`正在向纯`npm`包管理迁移,插件还在使用`git`,请继续安装。
- 目前`Karin``karin官方插件`正在向纯`npm`包管理迁移,较多数插件还在使用`git`,请继续安装。

## 部署karin

Expand All @@ -52,10 +52,18 @@ npm --registry=https://registry.npmmirror.com install pnpm -g

先新建一个空白文件夹,以下命令在文件夹里面执行,执行完成不出意外已经启动完毕了~

```bash
pnpm i node-karin && npx init && npx karin .
::: code-group

```bash [通用]
pnpm init && pnpm i node-karin && npx init && npx karin .
```

```powershell [powershell]
pnpm init; pnpm i node-karin; npx init; npx karin .
```

:::

### 基本指令

> [!IMPORTANT] 务必注意
Expand Down Expand Up @@ -106,12 +114,6 @@ npx karin log
如果你是中国大陆服务器,并且无法访问`npm`官方源,这里请务必更换为镜像源。
:::

- 查询当前镜像源

```bash
npm config get registry
```

- 更换镜像源

::: code-group
Expand All @@ -130,6 +132,10 @@ npm config set registry https://mirrors.cloud.tencent.com/npm
npm config set registry https://registry.npmjs.org
```

```bash [查询当前源]
npm config get registry
```

:::

</details>
Expand Down

0 comments on commit 7d974f1

Please sign in to comment.