npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koishi-plugin-currency

v0.1.3-alpha

Published

A currency plugin for koishi framework

Downloads

156

Readme

koishi-plugin-currency

npm

A currency plugin for koishi framework

This plugin is still under development! The API and the service signature may change in the future.

简单样例 Example

import {} from 'koishi-plugin-economic'
//....
export function apply(ctx:Context){
    ctx.currency.extends('money')
    ctx.command('any-command',{
      cost:30,          // 花费的数量
      currency:'money', // 指定货币类型
      revertOnFail:true // 这里默认就是true
    })
      .action(()=>{
          return '花费了30块!'
      })
  ctx.command('recharge')
    .alias('充值')
    .action(({session})=>{
      session.add('money',100,'说明一下增加/减少余额原因,比如recharge')
      return '充值成功!'
    })
  ctx.currency.add('money',anyUserId,100,'说明一下增加/减少余额原因,比如recharge')
}

API Documentation

Currency API

交易API

currency.extends(name:string)

向系统声明一个父货币类型(也就是从插件无需进行声明)

currency.add(name:string,userId:number,amount:number,reason:string)

增加用户拥有的某种货币数量

currency.cost(name:string,userId:number,amount:number,reason:string)

消耗用户拥有的某种货币数量

currency.get(name:string,userId:number)

获取用户拥有的某种货币数量

currency.set(name:string,userId:number,amount:number,reason:string)

设置用户拥有的某种货币数量

currency.deposit(name:string,userId:number,amount:number,reason:string)

抵押用户拥有的某种货币数量

currency.transfer(name:string,fromUserId:number,toUserId:number,amount:number,reason:string)

转移用户拥有的某种货币数量

交易操作API

currency.confirm(transaction:Transaction|number)

确认之前的抵押交易,可以传入Transaction或者number(Transaction.ID)

currency.revert(transaction:Transaction|number)

撤销之前的交易(包括抵押交易和普通交易),可以传入Transaction或者number(Transaction.ID)

Session API

交易API

session.add(name:string,amount:number,reason:string)

增加Session对应用户拥有的某种货币数量

session.cost(name:string,amount:number,reason:string)

消耗Session对应用户拥有的某种货币数量

session.getBalance(name:string)

获取Session对应用户拥有的某种货币数量

session.setBalance(name:string,amount:number,reason:string)

设置Session对应用户拥有的某种货币数量

session.deposit(name:string,amount:number,reason:string)

抵押Session对应用户拥有的某种货币数量

session.transfer(name:string,toUserId:number,amount:number,reason:string)

转移Session对应用户拥有的某种货币数量