@hieuzest/koishi-plugin-mahjongpub 0.1.12 → 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 CHANGED
@@ -35,6 +35,7 @@ export declare namespace MahjongPub {
35
35
  informNotbind: boolean;
36
36
  endpoint: string;
37
37
  batchInterval: number;
38
+ batchCount: number;
38
39
  }
39
40
  const Config: Schema<Config>;
40
41
  }
package/lib/index.js CHANGED
@@ -229,6 +229,7 @@ class MahjongPub {
229
229
  .option('team', '-t <team:string>')
230
230
  .option('start', '-s <start:number>')
231
231
  .option('end', '-e <end:number>')
232
+ .option('slim', '--slim')
232
233
  .userFields(['mahjongpub/bind-team', 'mahjongpub/bind-teams'])
233
234
  .channelFields(['mahjongpub/bind-team', 'mahjongpub/bind-contest', 'mahjongpub/bind-contestpw'])
234
235
  .action(async ({ session, options }, ...indices) => {
@@ -245,18 +246,22 @@ class MahjongPub {
245
246
  else if (options.start && options.end) {
246
247
  if (options.end - options.start > 100)
247
248
  return session.text('.wide-range');
249
+ const msg = [];
248
250
  for (let tid = options.start; tid <= options.end; tid++) {
249
- await session.execute({
251
+ msg.push(await session.execute({
250
252
  name: 'mahjongpub.team.swap',
251
253
  args: indices,
252
254
  options: {
253
255
  channel: options.channel,
254
256
  team: `${tid}`,
257
+ slim: true,
255
258
  },
256
- });
259
+ }, true));
260
+ if (msg.length >= config.batchCount)
261
+ await session.send(msg.splice(0).join('\n'));
257
262
  await ctx.sleep(config.batchInterval);
258
263
  }
259
- return '';
264
+ return msg.length ? msg.join('\n') : '';
260
265
  }
261
266
  if (!pw)
262
267
  return config.informNotbind ? session.text('.notbind') : '';
@@ -272,7 +277,10 @@ class MahjongPub {
272
277
  }
273
278
  const msg = await team.write();
274
279
  await team.read(true);
275
- return msg + '\n' + session.text('.success', team);
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);
276
284
  }
277
285
  catch (e) {
278
286
  ctx.logger.warn(e);
@@ -337,7 +345,8 @@ exports.MahjongPub = MahjongPub;
337
345
  MahjongPub.Config = koishi_1.Schema.object({
338
346
  informNotbind: koishi_1.Schema.boolean().default(false),
339
347
  endpoint: koishi_1.Schema.string().default('https://cdn.r-mj.com/'),
340
- batchInterval: koishi_1.Schema.natural().default(500),
348
+ batchInterval: koishi_1.Schema.natural().default(300),
349
+ batchCount: koishi_1.Schema.natural().default(10),
341
350
  });
342
351
  })(MahjongPub || (exports.MahjongPub = MahjongPub = {}));
343
352
  exports.default = MahjongPub;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hieuzest/koishi-plugin-mahjongpub",
3
3
  "description": "Mahjong.pub API",
4
- "version": "0.1.12",
4
+ "version": "0.1.13",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [