Git Product home page Git Product logo

koishi-plugin-eula's Introduction

koishi-plugin-eula

npm Rating

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

普通用户直接使用

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

开发扩展 eula 能力 (1.0+)

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

# yarn:

yarn add koishi-plugin-eula -d

# or use npm

npm i koishi-plugin-eula -d

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

//package.json

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

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

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

import {} from 'koishi-plugin-eula'

export const using = ['eula', ...]

最后,在您的插件中通过 eula/update 事件来获得 eula 状态,并根据状态自行调整:

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 来告知用户同意与否

koishi-plugin-eula's People

Contributors

lipraty avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

koishi-plugin-eula's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.