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-pcr

v1.0.4

Published

PCR plugin for Koishi

Downloads

347

Readme

npm

配置项

config.root

  • 类型: string
  • 默认值: data/pcr

存储图片资源文件的路径,相对于 koishi 的工作目录。

config['landosol-roster']

  • 类型: boolean
  • 默认值: false

是否使用本地的兰德索尔花名册数据源。需要安装 pcr-landosol-roster 插件。启用后,将会接管下一项配置的数据源。

config.source

  • 类型: string
  • 默认值: Ghproxy 代理的 Github

兰德索尔花名册数据源,需要能直接访问到目录下的 json 文件。

类型定义

interface Result {
  [key: string]: string[]
}

interface Chara {
  [key: string]: string
}

interface CharacterProfile {
  名字: string
  公会: string
  生日: string
  年龄: string
  身高: string
  体重: string
  血型: string
  种族: string
  喜好: string
  声优: string
  ...
}

export interface CharacterProfiles {
  [key: string]: CharacterProfile
}

export interface ImageInfo {
  buffer: Buffer | Image
  type: string
}

实例方法

pcr.getRoot()

  • 返回值: string

获得当前插件的资源文件根目录,为 ctx.baseDir 连接 config.root

pcr.getImage(url, fullPath, canvas?)

  • 参数:
    • url: string - 资源地址
    • fullPath: string - 存储资源的完整路径
    • canvas?: boolean - 是否返回 Canvas 的 Image 对象
  • 返回值: Promise<ImageInfo>

获取图片资源。会首先尝试从本地获取,如果不存在则从 url 下载并保存到 fullPath

pcr.getCardProfile(id, star, canvas?)

  • 参数:
    • id: string - 角色 ID
    • star: string - 角色星级,16
    • canvas?: boolean - 是否返回 Canvas 的 Image 对象
  • 返回值: Promise<ImageInfo>

获取角色卡片图片。

pcr.getUnitIcon(id, star, canvas?)

  • 参数:
    • id: string - 角色 ID
    • star: string - 角色星级,16
    • canvas?: boolean - 是否返回 Canvas 的 Image 对象
  • 返回值: Promise<ImageInfo>

获取角色头像图片。

pcr.getCardFull(id, star, canvas?)

  • 参数:
    • id: string - 角色 ID
    • star: string - 角色星级,16
    • canvas?: boolean - 是否返回 Canvas 的 Image 对象
  • 返回值: Promise<ImageInfo>

获取角色全身完整图片。

pcr.initCharaName(res?)

初始化角色名字及昵称。会将其存入字典树中以便使用。

pcr.initCharaProfile(res?)

初始化角色资料。

pcr.initUnavailableChara(res?)

初始化未实装的角色的 ID。

pcr.isReloading()

  • 返回值: boolean

获得 pcr 插件的数据状态

pcr.reloadRoster()

重新加载本地的 兰德索尔花名册 数据。需要安装 pcr-landosol-roster 插件。

pcr.clearRoster()

清除 兰德索尔花名册 数据。

pcr.getCharaProfile(id)

  • 参数:
    • id: string - 角色 ID
  • 返回值: CharacterProfile

获取角色资料。

pcr.isUnavailableChara(id)

  • 参数:
    • id: string - 角色 ID
  • 返回值: boolean

判断角色是否未实装。

pcr.parseTeam(str, toID?)

  • 参数:
    • str: string - 队伍字符串
    • toID?: boolean - 是否转换为角色 ID
  • 返回值: string[] | [boolean, string]

解析队伍字符串。解析成功则返回包含角色名的数组,如果 toIDtrue,则会将角色名称转换为角色 ID。如果遇到无法解析的角色,则会返回一个包含 false 和无法解析的角色名的数组。