Skip to content

Commit

Permalink
docs: init adapter docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 25, 2021
1 parent 6d82272 commit d5a5e67
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
8 changes: 8 additions & 0 deletions docs/api/adapter/discord.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ sidebarDepth: 2
---

# koishi-adapter-discord

## 注册机器人

1. 前往 [https://discord.com/developers/applications](https://discord.com/developers/applications),登录账号创建一个应用
2. 点击「Bot」并创建一个新的机器人,保存这个页面中的 token(请注意不要泄露)
3. 要将机器人拉进你的服务器,点击「OAuth2」,并在网址生成器中勾选 Bot 和机器人所需要的权限
4. 打开生成的链接,选择你具有管理权限的服务器,就成功把机器人添加进去了
5. 将上面的 token 作为机器人配置项即可使用
8 changes: 8 additions & 0 deletions docs/api/adapter/kaiheila.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ sidebarDepth: 2
---

# koishi-adapter-kaiheila

## 注册机器人

1. 前往 [开发者平台](https://developer.kaiheila.cn/),选择「机器人」并点击「新建」
2. 在机器人连接模式中配置 Webhook 或 WebSocket 中的一种:
- 如果是 Webhook,请记下页面中的 token 和 verify_token,并作为机器人的配置项,同时让 Koishi 暴露一个 URL,填入下方的 Callback URL 中,启动 Koishi 后点击「机器人上线」
- 如果是 WebSocket,则只需记录 token 并作为机器人的配置项即可,你可以在任何时候启动 Koishi
- 页面中的其他值不用管,但请注意 token 不要泄露
4 changes: 4 additions & 0 deletions docs/api/adapter/onebot.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ sidebarDepth: 2

# koishi-adapter-onebot

::: warning
尽管 Koishi 使用了 [MIT](https://choosealicense.com/licenses/mit/) 协议,但 OneBot 相关框架普遍使用了基于 [AGPL 3.0](https://choosealicense.com/licenses/agpl-3.0/) 的协议。因此如果你使用 koishi-adapter-onebot 运行你的机器人,你将可能受到 AGPL 3.0 协议的限制,必须将你的代码开源并保持同协议。Koishi 及其作者对使用上述框架或违反上述限制的行为所可能造成的一切后果概不负责。
:::

[OneBot](https://github.com/howmanybots/onebot) (旧名 CQHTTP) 是一个聊天机器人应用接口标准,目前可用于 QQ 机器人。要使用 koishi-adapter-onebot,你需要首先下载一个实现该协议的框架:

- [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp)(推荐)
Expand Down
10 changes: 10 additions & 0 deletions docs/api/adapter/telegram.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ sidebarDepth: 2
---

# koishi-adapter-telegram

## 注册机器人

1. 搜索 @botfather(有个官方认证的符号)并进入聊天界面
2. 输入 `/start` 后,会出现一个使用菜单,你可以使用这里指令对你的机器人进行配置
3. 要创建一个机器人,请点击 `/newbot`,并根据系统提示完成创建流程
4. 使用 `/setprivacy` 开启 Privacy Mode(不然机器人只能收到特定消息)
5. 创建完毕后,你会获得一个 token(请注意不要泄露),将其作为机器人配置项即可使用

参考文档:[https://core.telegram.org/bots](https://core.telegram.org/bots)
10 changes: 4 additions & 6 deletions docs/guide/starter.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Koishi 需要 [NodeJS](https://nodejs.org/) (v12 以上) 运行环境,你需

Koishi 支持多个聊天平台,对于不同的平台,你也需要做好相应的准备工作。

### OneBot (QQ)
### [OneBot (QQ)](../api/adapter/onebot.md)

[OneBot](https://github.com/howmanybots/onebot) 是一个聊天机器人应用接口标准,目前可用于 QQ 聊天机器人的实现。你可以使用下列实现该协议的框架:

Expand All @@ -20,9 +20,7 @@ Koishi 支持多个聊天平台,对于不同的平台,你也需要做好相

对于每一种框架,请分别参考它们对应的文档。

请注意:尽管 Koishi 使用的协议是 [MIT](https://choosealicense.com/licenses/mit/) 协议,但上面陈述的三种途径的相关框架都使用了基于 [AGPL 3.0](https://choosealicense.com/licenses/agpl-3.0/) 的协议。**因此如果你使用 koishi-adapter-onebot 运行你的机器人,你将可能受到 AGPL 3.0 协议的限制,必须将你的代码开源并保持同协议**。Koishi 及其作者对使用上述框架或违反上述限制的行为所可能造成的一切后果概不负责。

### Telegram (Telegram)
### [Telegram (Telegram)](../api/adapter/telegram.md)

1. 搜索 @botfather(有个官方认证的符号)并进入聊天界面
2. 输入 `/start` 后,会出现一个使用菜单,你可以使用这里指令对你的机器人进行配置
Expand All @@ -32,15 +30,15 @@ Koishi 支持多个聊天平台,对于不同的平台,你也需要做好相

参考文档:[https://core.telegram.org/bots](https://core.telegram.org/bots)

### Discord (Discord)
### [Discord (Discord)](../api/adapter/discord.md)

1. 前往 [https://discord.com/developers/applications](https://discord.com/developers/applications),登录账号创建一个应用
2. 点击「Bot」并创建一个新的机器人,保存这个页面中的 token(请注意不要泄露)
3. 要将机器人拉进你的服务器,点击「OAuth2」,并在网址生成器中勾选 Bot 和机器人所需要的权限
4. 打开生成的链接,选择你具有管理权限的服务器,就成功把机器人添加进去了
5. 将上面的 token 作为机器人配置项即可使用

### 开黑啦 (Kaiheila)
### [开黑啦 (Kaiheila)](../api/adapter/kaiheila.md)

1. 前往 [开发者平台](https://developer.kaiheila.cn/),选择「机器人」并点击「新建」
2. 在机器人连接模式中配置 Webhook 或 WebSocket 中的一种:
Expand Down
1 change: 0 additions & 1 deletion docs/plugins/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Koishi 官方提供了许多插件。为了更好地模块化开发,它们被
- [plugin-github](./other/github.md) / 接入 GitHub
- [plugin-image-search](./other/image-search.md) / 图片搜索
- [plugin-puppeteer](./other/puppeteer.md) / 网页截图
<!-- - [plugin-rss](./other/rss.md) / 订阅 RSS -->
- [plugin-schedule](./other/schedule.md) / 计划任务
- [plugin-tools](./other/tools.md) / 实用工具
- [plugin-webui](./other/webui.md) / 网页控制台
2 changes: 1 addition & 1 deletion packages/plugin-mysql/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class MysqlDatabase {
return keys.map((key) => {
if (typeof data[key] !== 'object' || types.isDate(data[key])) return data[key]
const type = MysqlDatabase.tables[table]?.[key]
if (type && typeof type !== 'string') return type.toString(data[key])
if (type && typeof type !== 'string') return type.stringify(data[key])
return JSON.stringify(data[key])
})
}
Expand Down

0 comments on commit d5a5e67

Please sign in to comment.