@hieuzest/koishi-plugin-mahjongpub 0.1.11 → 0.1.13
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.d.ts +2 -0
- package/lib/index.js +29 -1
- package/lib/locales/zh-CN.json +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -227,6 +227,9 @@ class MahjongPub {
|
|
|
227
227
|
.alias('!交换', '!交换')
|
|
228
228
|
.option('channel', '-c <channel:channel>')
|
|
229
229
|
.option('team', '-t <team:string>')
|
|
230
|
+
.option('start', '-s <start:number>')
|
|
231
|
+
.option('end', '-e <end:number>')
|
|
232
|
+
.option('slim', '--slim')
|
|
230
233
|
.userFields(['mahjongpub/bind-team', 'mahjongpub/bind-teams'])
|
|
231
234
|
.channelFields(['mahjongpub/bind-team', 'mahjongpub/bind-contest', 'mahjongpub/bind-contestpw'])
|
|
232
235
|
.action(async ({ session, options }, ...indices) => {
|
|
@@ -240,6 +243,26 @@ class MahjongPub {
|
|
|
240
243
|
await contest.read();
|
|
241
244
|
pw = (contest.teams[options.team] ?? Object.values(contest.teams).find(t => t.name === options.team))?.pw;
|
|
242
245
|
}
|
|
246
|
+
else if (options.start && options.end) {
|
|
247
|
+
if (options.end - options.start > 100)
|
|
248
|
+
return session.text('.wide-range');
|
|
249
|
+
const msg = [];
|
|
250
|
+
for (let tid = options.start; tid <= options.end; tid++) {
|
|
251
|
+
msg.push(await session.execute({
|
|
252
|
+
name: 'mahjongpub.team.swap',
|
|
253
|
+
args: indices,
|
|
254
|
+
options: {
|
|
255
|
+
channel: options.channel,
|
|
256
|
+
team: `${tid}`,
|
|
257
|
+
slim: true,
|
|
258
|
+
},
|
|
259
|
+
}, true));
|
|
260
|
+
if (msg.length >= config.batchCount)
|
|
261
|
+
await session.send(msg.splice(0).join('\n'));
|
|
262
|
+
await ctx.sleep(config.batchInterval);
|
|
263
|
+
}
|
|
264
|
+
return msg.length ? msg.join('\n') : '';
|
|
265
|
+
}
|
|
243
266
|
if (!pw)
|
|
244
267
|
return config.informNotbind ? session.text('.notbind') : '';
|
|
245
268
|
if (!indices.length || indices.length % 2 !== 0)
|
|
@@ -254,7 +277,10 @@ class MahjongPub {
|
|
|
254
277
|
}
|
|
255
278
|
const msg = await team.write();
|
|
256
279
|
await team.read(true);
|
|
257
|
-
|
|
280
|
+
if (options.slim)
|
|
281
|
+
return `[${team.tid} ${team.name}] ${msg} ` + indices.map(i => `${i}. ${team.players[i - 1]}`).join(' ');
|
|
282
|
+
else
|
|
283
|
+
return msg + '\n' + session.text('.success', team);
|
|
258
284
|
}
|
|
259
285
|
catch (e) {
|
|
260
286
|
ctx.logger.warn(e);
|
|
@@ -319,6 +345,8 @@ exports.MahjongPub = MahjongPub;
|
|
|
319
345
|
MahjongPub.Config = koishi_1.Schema.object({
|
|
320
346
|
informNotbind: koishi_1.Schema.boolean().default(false),
|
|
321
347
|
endpoint: koishi_1.Schema.string().default('https://cdn.r-mj.com/'),
|
|
348
|
+
batchInterval: koishi_1.Schema.natural().default(300),
|
|
349
|
+
batchCount: koishi_1.Schema.natural().default(10),
|
|
322
350
|
});
|
|
323
351
|
})(MahjongPub || (exports.MahjongPub = MahjongPub = {}));
|
|
324
352
|
exports.default = MahjongPub;
|
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":"参数错误","success":"- [{cid}:{tid}] {name}\n{players.map((p, i) => '' + (i+1) + ': ' + p).join('\\n')}\n"}},"mahjongpub.contest.bind":{"description":"绑定比赛","messages":{"failed":"绑定失败","success":"成功: [{cid}] {name}"}}}}
|
|
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}"}}}}
|