Skip to content
ChatLunaLabPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

@chatluna/qface

A maintenance fork of qface (MIT, Shigma). The QQ system face table: 275 faces with their ids, Chinese names and pinyin shortcuts, plus the url each one is served as. Zero dependencies, Node 20+.

npm install @chatluna/qface
import { data, findFace, getFace, getFaceUrl } from '@chatluna/qface'

getFace(14) // { QSid: '14', QDes: '/微笑', EMCode: '100', Input: ['weixiao', 'wx'], … }
findFace('jk') // '26', also 'jingkong', '/微笑', 'wx'…
getFaceUrl(178) // https://koishi.js.org/QFace/gif/s178.gif
getFaceUrl(347) // https://koishi.js.org/QFace/static/s347.png — isStatic faces are png

API

data

The whole Face[] table, keyed by the string QSid. A face carries QDes (the /-prefixed Chinese name), the historical IQLid/AQLid/EMCode codes, and optional flags: isStatic for faces that only exist as a png, AniStickerType/AniStickerId for the animated-sticker faces, QHide for faces not in the picker. Input lists the pinyin inputs, full spellings before abbreviations, and is absent on the newest faces.

getFace(id)

The face with QSid === String(id), or undefined.

findFace(input)

The QSid of the first face matching input, or null. Matches, in order: a QDes equal to the input (a leading / on the input is ignored), an exact Input entry, then an Input entry that starts with the input — so 'j' finds /惊恐 first because its Input starts with jk.

getFaceUrl(id, base?)

{base}/gif/s{id}.gif, or {base}/static/s{id}.png when isStatic is set. base defaults to https://koishi.js.org/QFace, the public mirror; pass your own host to serve the images yourself. Returns '' for an unknown id.

Sync

src/data.json is a checked-in copy of lib/data.json from koishijs/QFace; src/data.ts inlines it as a module, so the package runs in browsers and bundlers without node:fs. Refresh both with:

yarn sync   # fetches the current table and rewrites src/data.json and src/data.ts
yarn test   # builds lib/ and runs the unit tests

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages