Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 14, 2022
2 parents de9cda6 + c83a547 commit 88f45f1
Show file tree
Hide file tree
Showing 191 changed files with 4,123 additions and 2,255 deletions.
10 changes: 5 additions & 5 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ const specs = [
'community/schemastery/tests/*.spec.ts',
'packages/core/tests/*.spec.ts',
'packages/utils/tests/*.spec.ts',
'plugins/common/admin/tests/*.spec.ts',
'plugins/a11y/admin/tests/*.spec.ts',
'plugins/a11y/rate-limit/tests/*.spec.ts',
'plugins/a11y/switch/tests/*.spec.ts',
'plugins/a11y/sudo/tests/*.spec.ts',
// 'plugins/a11y/verifier/tests/*.spec.ts',
'plugins/common/broadcast/tests/*.spec.ts',
'plugins/common/contextify/tests/*.spec.ts',
'plugins/common/echo/tests/*.spec.ts',
'plugins/common/feedback/tests/*.spec.ts',
'plugins/common/forward/tests/*.spec.ts',
'plugins/common/rate-limit/tests/*.spec.ts',
'plugins/common/recall/tests/*.spec.ts',
'plugins/common/repeater/tests/*.spec.ts',
'plugins/common/respondent/tests/*.spec.ts',
'plugins/common/switch/tests/*.spec.ts',
// 'plugins/common/verifier/tests/*.spec.ts',
'plugins/database/level/tests/*.spec.ts',
'plugins/database/memory/tests/*.spec.ts',
'plugins/database/mongo/tests/*.spec.ts',
Expand Down
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Koishi 完全基于 TypeScript 开发,拥有顶级的类型支持,丰富的

## 官方插件

### 平台支持
### 适配器支持

- [adapter-discord](https://koishi.js.org/plugins/adapter/discord.html): [Discord](https://discord.com/) 平台支持
- [adapter-kaiheila](https://koishi.js.org/plugins/adapter/kaiheila.html): [开黑啦](https://kaiheila.cn/) 平台支持
Expand All @@ -95,38 +95,49 @@ Koishi 完全基于 TypeScript 开发,拥有顶级的类型支持,丰富的
- [assets-remote](https://koishi.js.org/plugins/assets/remote.html): 使用远程 Koishi 服务器存储静态资源
- [assets-s3](https://koishi.js.org/plugins/assets/s3.html): 使用 S3 存储静态资源

### 缓存支持

- [cache-lru](https://koishi.js.org/plugins/cache/lru.html): LRU 缓存支持
- [cache-redis](https://koishi.js.org/plugins/cache/redis.html): Redis 缓存支持

### 数据库支持

- [database-level](https://koishi.js.org/plugins/database/level.html): LevelDB 数据库支持
- [database-memory](https://koishi.js.org/plugins/database/memory.html): 测试用的内存数据库支持
- [database-mongo](https://koishi.js.org/plugins/database/mongo.html): MongoDB 数据库支持
- [database-mysql](https://koishi.js.org/plugins/database/mysql.html): MySQL 数据库支持
- [database-sqlite](https://koishi.js.org/plugins/database/sqlite.html): SQLite 数据库支持

## 常用功能

- [broadcast](https://koishi.js.org/plugins/common/broadcast.html):发送广播
- [echo](https://koishi.js.org/plugins/common/echo.html):发送消息
- [feedback](https://koishi.js.org/plugins/common/feedback.html):发送反馈
- [forward](https://koishi.js.org/plugins/common/forward.html):转发消息
- [recall](https://koishi.js.org/plugins/common/recall.html):撤回消息
- [repeater](https://koishi.js.org/plugins/common/repeater.html):复读机
- [respondent](https://koishi.js.org/plugins/common/respondent.html):快捷回复

## 辅助功能

- [admin](https://koishi.js.org/plugins/accessibility/admin.html):数据管理
- [bind](https://koishi.js.org/plugins/accessibility/bind.html):账号绑定
- [callme](https://koishi.js.org/plugins/accessibility/callme.html):设置昵称
- [rate-limit](https://koishi.js.org/plugins/accessibility/rate-limit.html):速率控制
- [schedule](https://koishi.js.org/plugins/accessibility//schedule.html):计划任务
- [sudo](https://koishi.js.org/plugins/accessibility/sudo.html):模拟调用
- [verifier](https://koishi.js.org/plugins/accessibility/verifier.html):处理申请

### 网页控制台

- [chat](https://koishi.js.org/plugins/console/chat.html): 使用机器人账号聊天
- [chat](https://koishi.js.org/plugins/console/chat.html): 聊天工具
- [console](https://koishi.js.org/plugins/console/): 网页控制台
- [manager](https://koishi.js.org/plugins/console/manager.html): 管理插件和机器人
- [status](https://koishi.js.org/plugins/console/status.html): 查看运行状态和统计数据
- [commands](https://koishi.js.org/plugins/console/commands.html): 指令管理
- [manager](https://koishi.js.org/plugins/console/manager.html): 插件管理
- [status](https://koishi.js.org/plugins/console/status.html): 运行状态

### 其他官方插件

- [admin](https://koishi.js.org/plugins/admin.html): 操作用户数据和频道数据
- [common](https://koishi.js.org/plugins/common.html): 常用指令合集
- [eval](https://koishi.js.org/plugins/eval.html): 对话机器人执行脚本
- [forward](https://koishi.js.org/plugins/forward.html): 转发消息到其他频道
- [eval](https://koishi.js.org/plugins/eval/): 对话机器人执行脚本
- [github](https://koishi.js.org/plugins/github.html): GitHub 相关功能
- [mock](https://koishi.js.org/plugins/mock.html): 模拟消息、会话、网络请求
- [puppeteer](https://koishi.js.org/plugins/puppeteer.html): 网页截图和图片渲染
- [repeater](https://koishi.js.org/plugins/repeater.html): 复读机相关功能
- [schedule](https://koishi.js.org/plugins/schedule.html): 设置和执行计划任务
- [teach](https://koishi.js.org/plugins/teach.html): 教学问答系统
- [verifier](https://koishi.js.org/plugins/verifier.html): 处理好友和群组请求
- [teach](https://koishi.js.org/plugins/teach/): 教学问答系统

## 应用案例

Expand All @@ -142,6 +153,7 @@ Koishi 完全基于 TypeScript 开发,拥有顶级的类型支持,丰富的
| [assets-smms](https://github.com/koishijs/koishi-plugin-assets-smms) | 使用 sm.ms 存储静态资源文件 |
| [chess](https://github.com/koishijs/koishi-plugin-chess) | 棋类游戏 |
| [dice](https://github.com/koishijs/koishi-plugin-dice) | 掷骰 |
| [gocqhttp](https://github.com/koishijs/koishi-plugin-gocqhttp) | [gocqhttp](https://github.com/Mrs4s/go-cqhttp) 启动器 |
| [image-search](https://github.com/koishijs/koishi-plugin-image-search) | 图源搜索 |
| [pics](https://github.com/koishijs/koishi-plugin-pics) | 随机图片 |
| [rss](https://github.com/koishijs/koishi-plugin-rss) | RSS 订阅 |
Expand Down
1 change: 1 addition & 0 deletions build/bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const packages: Record<string, Package> = {}
function getPackage(name: string) {
return packages[`packages/${name}`]
|| packages[`plugins/${name}`]
|| packages[`plugins/a11y/${name}`]
|| packages[`plugins/adapter/${name}`]
|| packages[`plugins/assets/${name}`]
|| packages[`plugins/cache/${name}`]
Expand Down
2 changes: 1 addition & 1 deletion build/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function getVersion(name: string, isNext = false) {
}

const { version } = require('../packages/koishi/package') as PackageJson
if (isNext(version)) return
if (!CI || isNext(version)) return

const tags = spawnSync(['git', 'tag', '-l']).split(/\r?\n/)
if (tags.includes(version)) {
Expand Down
1 change: 1 addition & 0 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function getWorkspaces() {
const categories = [
'packages',
'plugins',
'plugins/a11y',
'plugins/adapter',
'plugins/assets',
'plugins/cache',
Expand Down
43 changes: 25 additions & 18 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ module.exports = {
isGroup: true,
children: [
'/guide/service/assets.md',
'/guide/service/cache.md',
'/guide/service/http.md',
'/guide/service/route.md',
'/guide/service/logger.md',
Expand Down Expand Up @@ -164,12 +163,6 @@ module.exports = {
'/api/utils/logger.md',
'/api/utils/misc.md',
],
}, {
text: '其他官方包',
isGroup: true,
children: [
'/api/tools/cli.md',
],
}, {
text: '更新与迁移',
isGroup: true,
Expand Down Expand Up @@ -210,27 +203,42 @@ module.exports = {
'/plugins/assets/remote.md',
'/plugins/assets/s3.md',
],
}, {
text: '常用功能',
isGroup: true,
children: [
'/plugins/common/broadcast.md',
'/plugins/common/echo.md',
'/plugins/common/feedback.md',
'/plugins/common/forward.md',
'/plugins/common/recall.md',
'/plugins/common/repeater.md',
'/plugins/common/respondent.md',
],
}, {
text: '辅助功能',
isGroup: true,
children: [
'/plugins/accessibility/admin.md',
'/plugins/accessibility/bind.md',
'/plugins/accessibility/callme.md',
'/plugins/accessibility/rate-limit.md',
'/plugins/accessibility/schedule.md',
'/plugins/accessibility/sudo.md',
'/plugins/accessibility/verifier.md',
],
}, {
text: '控制台开发',
isGroup: true,
children: [
'/plugins/console/index.md',
'/plugins/console/chat.md',
'/plugins/console/manager.md',
'/plugins/console/commands.md',
'/plugins/console/status.md',
'/plugins/console/server.md',
'/plugins/console/client.md',
],
}, {
text: '交互功能',
isGroup: true,
children: [
'/plugins/common/index.md',
'/plugins/common/basic.md',
'/plugins/common/handler.md',
'/plugins/common/repeater.md',
'/plugins/common/admin.md',
],
}, {
text: '教学系统 (Teach)',
isGroup: true,
Expand Down Expand Up @@ -269,7 +277,6 @@ module.exports = {
'/plugins/other/github.md',
'/plugins/other/mock.md',
'/plugins/other/puppeteer.md',
'/plugins/other/schedule.md',
],
}],
},
Expand Down
4 changes: 2 additions & 2 deletions docs/api/core/bot.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ sidebarDepth: 2

- **channelId:** `string` 频道 ID
- **content:** `string` 要发送的内容
- 返回值: `Promise<string>` 发送的消息 ID
- 返回值: `Promise<string[]>` 发送的消息 ID

向特定频道发送消息。

### bot.sendPrivateMessage(userId, content)

- **userId:** `string` 对方 ID
- **content:** `string` 要发送的内容
- 返回值: `Promise<string>` 发送的消息 ID
- 返回值: `Promise<string[]>` 发送的消息 ID

向特定用户发送私聊消息。

Expand Down
3 changes: 0 additions & 3 deletions docs/api/core/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ type Plugin<U> = PluginFunction<T, U> | PluginObject<T, U>
- **checkUnknown:** `boolean` 是否对未知选项进行检测,默认为 `false`
- **checkArgCount:** `boolean` 是否对参数个数进行检测,默认为 `false`
- **authority:** `number` 最低调用权限,默认为 `1`
- **maxUsage:** `number` 每天最多调用次数,默认为 `Infinity`
- **minInterval:** `number` 每次调用最短时间间隔,默认为 `0`
- **showWarning:** `boolean` 当小于最短间隔时是否进行提醒,默认为 `false`
- **usageName:** `string` 调用标识符,默认为指令名,如果多个指令使用同一个标识符,则它们的调用次数将合并计算
- 返回值:[`Command`](./command.md) 注册或修改的指令

在当前上下文中注册或修改一个指令。
Expand Down
1 change: 0 additions & 1 deletion docs/api/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export default {

- 接口变更
- 新增了方法 `db.set(table, query, updates)`
- 废弃了方法 `db.getAssignedChannels()`(目前暂无替代品,原接口仍然可用)
- `db.update()` 更名为 `db.upsert()`,语法不变
- 数据结构变更
- channel 表使用 `platform`+`id` 复合主键进行索引,这意味着 `channel.id` 语义将发生变化,同时新增了 `channel.platform`
Expand Down
5 changes: 0 additions & 5 deletions docs/api/tools/cli.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/guide/adapter/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MyBot extends Bot {
async sendMessage(channelId, content) {
// 这里应该执行发送操作
this.logger.debug('send:', content)
return Random.uuid()
return []
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@ class MyBot extends Bot {
async sendMessage(channelId: string, content: string) {
// 这里应该执行发送操作
this.logger.debug('send:', content)
return Random.uuid()
return []
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/command/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ app.command('echo').alias('say')

### 快捷方式

Koishi 的指令机制虽然能够尽可能避免冲突和误触发,但是也带来了一些麻烦。一方面,一些常用指令的调用会受到指令前缀的限制;另一方面,一些指令可能有较长的选项和参数,但它们调用时却往往是相同的。面对这些情况,**快捷方式**能有效地解决你的问题。
Koishi 的指令机制虽然能够尽可能避免冲突和误触发,但是也带来了一些麻烦。一方面,一些常用指令的调用会受到指令前缀的限制;另一方面,一些指令可能有较长的选项和参数,但它们调用时却往往是相同的。面对这些情况,**快捷方式 (Shortcut)** 能有效地解决你的问题。

假设你实现了一个货币系统和 rank 指令,调用 `rank wealth --global` 可以实现查看全服所有人财富排行,你可以这样做:

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/command/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebarDepth: 2
# 查看和编写帮助

::: tip
下面的 echo 指令是为了理解方便而举的例子,与 @koishijs/plugin-common 中实际的 echo 指令并不相同。
下面的 echo 指令是为了理解方便而举的例子,与 @koishijs/plugin-echo 中实际的 echo 指令并不相同。
:::

## 查看帮助
Expand Down
37 changes: 0 additions & 37 deletions docs/guide/database/builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,40 +136,3 @@ ctx.command('echo <message:text> 输出收到的信息', { authority: 2 })
```

这样一来,1 级或以下权限的用户就无法调用 echo 指令;2 级权限用户只能调用 echo 指令但不能使用 -t 参数;3 级或以上权限的用户不受限制。对于受限的用户,机器人将会回复“权限不足”。

### 设置访问次数上限

有些指令(例如签到抽卡点赞,高性能损耗的计算,限制次数的 API 调用等)我们并不希望被无限制调用,这时我们可以设置每天访问次数的上限:

```js
// 设置 lottery 指令每人每天只能调用 10 次
ctx.command('lottery 抽卡', { maxUsage: 10 })
// 设置使用了 -s 的调用不计入总次数
.option('--show', '-s 查看已经抽到的物品列表', { notUsage: true })
```

这样一来,所有访问 lottery 指令且不含 -s 选项的调用次数上限便被设成了 10 次。当超出总次数后,机器人将回复“调用次数已达上限”。

### 设置最短触发间隔

有些指令(例如高强度刷屏)我们并不希望被短时间内重复调用,这时我们可以设置最短触发间隔:

```js
const { Time } = require('koishi')

// 设置 lottery 指令每 60 秒只能调用 1 次
ctx.command('lottery', { minInterval: Time.minute })
```

这样一来,lottery 指令被调用后 60 秒内,如果再次被调用,将会提示“调用过于频繁,请稍后再试”。当然,`notUsage``minInterval` 也同样生效。

### 多指令共享调用限制

如果我们希望让多个指令共同同一个调用限制,可以通过 `usageName` 来实现:

```js
ctx.command('lottery 常驻抽卡', { maxUsage: 10 })
ctx.command('accurate 精准抽卡', { maxUsage: 10, usageName: 'lottery' })
```

这样一来,就能限制每天的 lottery 和 accurate 指令的调用次数之和不超过 10 了。
4 changes: 2 additions & 2 deletions docs/guide/introduction/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ plugins:
protocol: 'ws'
selfId: '123456789'
endpoint: 'ws://127.0.0.1:6700'
common:
echo:
```
让我们对比一下代码示例中的 `index.js` 文件,不难发现它们之间的相似:
Expand All @@ -56,7 +56,7 @@ app.plugin('adapter-onebot', {
endpoint: 'ws://127.0.0.1:6700',
})
app.plugin('common')
app.plugin('echo')
```

没错,配置文件中的 `plugins` 是一个对象,其中的每一个键表示一个插件的名称,而值则表示该插件的配置。而代码示例中的 `app.plugin()` 则接受最多两个参数,分别也是插件的短名和配置。
Expand Down
Loading

0 comments on commit 88f45f1

Please sign in to comment.