forked from idlist/koishi-plugin-jrrp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (42 loc) · 1.69 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { Schema: S } = require('koishi')
const core = require('./src/core.js')
module.exports.name = 'qiuqian'
const ToString = S.union([
S.string(),
S.transform(S.number(), n => `${n}`),
])
module.exports.schema = S.object({
useDatabase: S.boolean().default(true)
.description('是否使用数据库。数据库仅用来获取储存在其中的昵称。当没有数据库时,此项将被强制设为 `false`。'),
result: S.string()
.description('自定义结果语句。详情请查看 [README](https://github.com/idlist/koishi-plugin-qiuqian)。'),
useLevel: S.boolean().default(true)
.description('是否对人品值进行附加评价。'),
levels: S.dict(ToString, S.string())
.description('自定义评价语句。详情请查看 [README](https://github.com/idlist/koishi-plugin-qiuqian)。'),
useJackpot: S.boolean().default(true)
.description('是否对特定分值进行特殊评价。'),
jackpots: S.dict(ToString, S.string())
.description('自定义对特殊分值的评价语句。详情请查看 [README](https://github.com/idlist/koishi-plugin-qiuqian)。'),
})
/**
* @param {import('koishi').Context} ctx
* @param {import('./index').Config} config
*/
module.exports.apply = (ctx, config) => {
ctx.i18n.define('zh', require('./locales/zh'))
const log = ctx.logger('qiuqian')
config = {
useDatabase: true,
result: undefined,
useLevel: true,
levels: {},
useJackpot: true,
jackpots: {},
...config,
}
if (config.useLevel && Object.keys(config.levels).length && !config.levels['0']) {
log.warn('Level comments is used but comment is not provided at score 0. This may cause unexpected behavior.')
}
ctx.plugin(core, config)
}