@hieuzest/koishi-plugin-mahjongpub 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +68 -1
- package/lib/locales/zh-CN.json +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -351,6 +351,73 @@ class MahjongPub {
|
|
|
351
351
|
return session.text('.failed');
|
|
352
352
|
}
|
|
353
353
|
});
|
|
354
|
+
if (ctx.get('mahjong.database')) {
|
|
355
|
+
ctx.command('mahjongpub.database.record.get <round:natural> <cls:natural>', { authority: 3 })
|
|
356
|
+
.option('rowi', '-i <rowi:integer>', { fallback: 9 })
|
|
357
|
+
.option('ver', '-v <ver:integer>', { fallback: 0 })
|
|
358
|
+
.channelFields(['mahjongpub/bind-contest'])
|
|
359
|
+
.action(async ({ session, options }, round, cls) => {
|
|
360
|
+
const [cid] = [session.channel['mahjongpub/bind-contest']];
|
|
361
|
+
try {
|
|
362
|
+
const record = await ctx.mahjong.database.db('scoreboard').collection('matches').findOne({
|
|
363
|
+
cid,
|
|
364
|
+
cls,
|
|
365
|
+
round,
|
|
366
|
+
rowi: options.rowi,
|
|
367
|
+
ver: options.ver,
|
|
368
|
+
});
|
|
369
|
+
if (!record)
|
|
370
|
+
return session.text('.failed');
|
|
371
|
+
return `[${options.rowi}] ` + record.results.map((x) => `${x.name} ${x.num}`).join(' / ');
|
|
372
|
+
}
|
|
373
|
+
catch (e) {
|
|
374
|
+
ctx.logger.warn(e);
|
|
375
|
+
return session.text('.failed');
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
ctx.command('mahjongpub.database.record.update <round:natural> <cls:natural> <...points:integer>', { authority: 4 })
|
|
379
|
+
.option('rowi', '-i <rowi:integer>', { fallback: 9 })
|
|
380
|
+
.option('ver', '-v <ver:integer>', { fallback: 0 })
|
|
381
|
+
.channelFields(['mahjongpub/bind-contest'])
|
|
382
|
+
.action(async ({ session, options }, round, cls, ...points) => {
|
|
383
|
+
const [cid] = [session.channel['mahjongpub/bind-contest']];
|
|
384
|
+
try {
|
|
385
|
+
const res = await ctx.mahjong.database.db('scoreboard').collection('matches').updateOne({
|
|
386
|
+
cid,
|
|
387
|
+
cls,
|
|
388
|
+
round,
|
|
389
|
+
rowi: options.rowi,
|
|
390
|
+
ver: options.ver,
|
|
391
|
+
}, {
|
|
392
|
+
$set: Object.fromEntries(points.map((p, i) => [`results.${i}.num`, p])),
|
|
393
|
+
});
|
|
394
|
+
return res.modifiedCount ? session.text('.success') : session.text('.failed');
|
|
395
|
+
}
|
|
396
|
+
catch (e) {
|
|
397
|
+
ctx.logger.warn(e);
|
|
398
|
+
return session.text('.failed');
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
ctx.command('mahjongpub.admin.record.get <round:natural> <cls:natural>', { authority: 3 })
|
|
402
|
+
.option('rowi', '-i <rowi:integer>', { fallback: 9 })
|
|
403
|
+
.option('ver', '-v <ver:integer>', { fallback: 0 })
|
|
404
|
+
.action(async ({ session, options }, round, cls) => {
|
|
405
|
+
const msg = [];
|
|
406
|
+
msg.push('- Mahjongpub');
|
|
407
|
+
msg.push(await session.execute({
|
|
408
|
+
name: 'mahjongpub.contest.record.get',
|
|
409
|
+
args: [round, cls],
|
|
410
|
+
options,
|
|
411
|
+
}, true));
|
|
412
|
+
msg.push('- Database');
|
|
413
|
+
msg.push(await session.execute({
|
|
414
|
+
name: 'mahjongpub.database.record.get',
|
|
415
|
+
args: [round, cls],
|
|
416
|
+
options,
|
|
417
|
+
}, true));
|
|
418
|
+
return msg.join('\n');
|
|
419
|
+
});
|
|
420
|
+
}
|
|
354
421
|
}
|
|
355
422
|
async getTeam(pw) {
|
|
356
423
|
// if (this.ctx.get('cache')) {
|
|
@@ -381,7 +448,7 @@ exports.MahjongPub = MahjongPub;
|
|
|
381
448
|
(function (MahjongPub) {
|
|
382
449
|
MahjongPub.inject = {
|
|
383
450
|
required: ['database'],
|
|
384
|
-
optional: ['assets', 'cache'],
|
|
451
|
+
optional: ['assets', 'cache', 'mahjong', 'mahjong.database'],
|
|
385
452
|
};
|
|
386
453
|
MahjongPub.Config = koishi_1.Schema.object({
|
|
387
454
|
informNotbind: koishi_1.Schema.boolean().default(false),
|
package/lib/locales/zh-CN.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commands":{"mahjongpub.team.bind":{"description":"绑定队伍","messages":{"failed":"绑定失败","success":"成功: [{cid}:{tid}] {name}"}},"mahjongpub.team.unbind":{"description":"解除绑定","messages":{"notbind":"未绑定","success":"成功"}},"mahjongpub.team.password":{"description":"查看密码","messages":{"notbind":"未绑定","output":"密码: {0}"}},"mahjongpub.team.stats":{"description":"查看队伍信息","messages":{"notbind":"未绑定","failed":"失败","output":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.team.desc":{"description":"队伍简介","messages":{"notbind":"未绑定","failed":"失败","output":"- [{cid}:{tid}] {name}\n{description}\n"}},"mahjongpub.team.logo":{"description":"队伍头像","messages":{"notbind":"未绑定","failed":"失败"}},"mahjongpub.team.add":{"description":"添加队员","messages":{"notbind":"未绑定","failed":"失败","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.team.remove":{"description":"删除队员","messages":{"notbind":"未绑定","failed":"失败","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.team.swap":{"description":"交换队员","messages":{"notbind":"未绑定","failed":"失败","invalid":"参数错误","wide-range":"范围过大","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.contest.bind":{"description":"绑定比赛","messages":{"failed":"绑定失败","success":"成功: [{cid}] {name}"}},"mahjongpub.contest.record.get":{"description":"查询比赛记录","messages":{"failed":"查询失败"}},"mahjongpub.contest.record.update":{"description":"修改比赛记录","messages":{"failed":"修改失败"}}}}
|
|
1
|
+
{"commands":{"mahjongpub.team.bind":{"description":"绑定队伍","messages":{"failed":"绑定失败","success":"成功: [{cid}:{tid}] {name}"}},"mahjongpub.team.unbind":{"description":"解除绑定","messages":{"notbind":"未绑定","success":"成功"}},"mahjongpub.team.password":{"description":"查看密码","messages":{"notbind":"未绑定","output":"密码: {0}"}},"mahjongpub.team.stats":{"description":"查看队伍信息","messages":{"notbind":"未绑定","failed":"失败","output":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.team.desc":{"description":"队伍简介","messages":{"notbind":"未绑定","failed":"失败","output":"- [{cid}:{tid}] {name}\n{description}\n"}},"mahjongpub.team.logo":{"description":"队伍头像","messages":{"notbind":"未绑定","failed":"失败"}},"mahjongpub.team.add":{"description":"添加队员","messages":{"notbind":"未绑定","failed":"失败","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.team.remove":{"description":"删除队员","messages":{"notbind":"未绑定","failed":"失败","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.team.swap":{"description":"交换队员","messages":{"notbind":"未绑定","failed":"失败","invalid":"参数错误","wide-range":"范围过大","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.contest.bind":{"description":"绑定比赛","messages":{"failed":"绑定失败","success":"成功: [{cid}] {name}"}},"mahjongpub.contest.record.get":{"description":"查询比赛记录","messages":{"failed":"查询失败"}},"mahjongpub.contest.record.update":{"description":"修改比赛记录","messages":{"failed":"修改失败"}},"mahjongpub.database.record.get":{"description":"查询比赛记录","messages":{"failed":"查询失败"}},"mahjongpub.database.record.update":{"description":"修改比赛记录","messages":{"success":"修改失败","failed":"修改失败"}}}}
|