# koishi-plugin-eula

> EULA(End-user licence agreement) for your koishi bot.

Latest version **1.2.0** (published 2023-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install koishi-plugin-eula
pnpm add koishi-plugin-eula
yarn add koishi-plugin-eula
bun add koishi-plugin-eula
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2023-07-29 |
| First published | 2023-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Lipraty |
| Maintainers | lipraty |
| Keywords | chatbot, koishi, plugin, eula, 用户许可协议, 群管 |

## Links

- npm: https://www.npmjs.com/package/koishi-plugin-eula
- Repository: https://github.com/Lipraty/koishi-plugin-eula
- npm.io page: https://npm.io/package/koishi-plugin-eula

## Recent versions

- 1.2.0 (latest) — 2023-07-29
- 1.1.3 — 2023-07-23
- 1.1.2 — 2023-07-08
- 1.1.1 — 2023-07-08
- 1.1.0 — 2023-05-27
- 1.0.4 — 2023-02-11
- 1.0.3 — 2023-02-11
- 1.0.2 — 2023-02-10
- 1.0.1 — 2023-02-09
- 1.0.0-alpha.3 — 2023-02-09
- 1.0.0-alpha.2 — 2023-02-09
- 1.0.0-alpha.1 — 2023-02-08
- 1.0.0-alpha.0 — 2023-02-08
- 0.1.1 — 2023-01-16
- 0.1.0 — 2023-01-15
- … 6 more at https://npm.io/package/koishi-plugin-eula/versions

## README

# koishi-plugin-eula

[![npm](https://img.shields.io/npm/v/koishi-plugin-eula?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-eula) ![Rating](https://badge.koishi.chat/rating/koishi-plugin-eula)

为你的 Koishi bot 添加一个 EULA(End-user licence agreement)

## 普通用户直接使用

在插件市场中搜索 `eula` 点击添加即可。

## 开发扩展 eula 能力 (1.0+)

首先需要添加 eula 开发模式依赖：

``` shell
# yarn:

yarn add koishi-plugin-eula -d

# or use npm

npm i koishi-plugin-eula -d
```

并且可以在 `package.json` 中加入如下 koishi 字段来声明 eula 依赖：

``` json
//package.json

...
  "koishi": {
    ...,
    "service": {
      "required": [..., "eula"]
    },
    ...
  },
...
```

然后，在您的插件中引入类型依赖来获得类型提示

以及添加 using 引用来让 koishi 正确的加载插件顺序：

``` TypeScript
import {} from 'koishi-plugin-eula'

export const using = ['eula', ...]
```
最后，在您的插件中通过 `eula/update` 事件来获得 eula 状态，并根据状态自行调整：

``` TypeScript
ctx.on('eula/update', (session: Session, eula: boolean) => {
    //more core
})
```

经过如上方式便可在您的插件中使用 eula 流程，或者基于 eula 的认证能力扩展出更多的玩法。

## API

### 服务：eula

#### `ctx.eula.vertify()`

> 一般情况下，更推荐使用 `eula/update` 事件来获得认证状态，这将得到完整 Session 支持

验证该用户是否同意过 `eula`

- userId: `number` 用户 id，即 session.user.id

### 扩展事件

事件：`eula/before`

命令触发 eula 流程**前**发生该事件

事件：`eula/update`

当用户回复 eula 后触发，这将传入一个 eula boolean 来告知用户同意与否

---
_Source: https://npm.io/package/koishi-plugin-eula · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
