@hieuzest/koishi-plugin-mahjongpub 0.2.1 → 0.2.2
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 +10 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context, Dict, Schema, Service } from 'koishi';
|
|
2
2
|
import { ContestAdmin, TeamAdmin } from './api';
|
|
3
|
+
import { ContestManager } from './manager';
|
|
3
4
|
declare module 'koishi' {
|
|
4
5
|
interface Context {
|
|
5
6
|
mahjongpub: MahjongPub;
|
|
@@ -39,6 +40,7 @@ export declare namespace MahjongPub {
|
|
|
39
40
|
endpoint: string;
|
|
40
41
|
batchInterval: number;
|
|
41
42
|
batchCount: number;
|
|
43
|
+
manager: ContestManager.Config;
|
|
42
44
|
}
|
|
43
45
|
const Config: Schema<Config>;
|
|
44
46
|
}
|
package/lib/index.js
CHANGED
|
@@ -357,6 +357,13 @@ var ContestManager = class {
|
|
|
357
357
|
if (options.clear) this.extra[cid].stopCls.clear();
|
|
358
358
|
return "Finished.";
|
|
359
359
|
});
|
|
360
|
+
ctx.command("contest.manager.deinit").channelFields(["mahjongpub/bind-contest"]).option("clear", "-c").action(async ({ session, options }) => {
|
|
361
|
+
const cid = +(session.channel["mahjongpub/bind-contest"] || 0);
|
|
362
|
+
if (!cid) return "Unauthorized.";
|
|
363
|
+
this.extra[cid] ??= new ContestExtra(ctx);
|
|
364
|
+
this.extra[cid].subscribers.delete(session.cid);
|
|
365
|
+
return "Finished.";
|
|
366
|
+
});
|
|
360
367
|
ctx.command("contest.manager.start [cls:number]").channelFields(["mahjongpub/bind-contest"]).action(async ({ session }, cls) => {
|
|
361
368
|
const cid = +(session.channel["mahjongpub/bind-contest"] || 0);
|
|
362
369
|
if (!cid) return "Unauthorized.";
|
|
@@ -468,7 +475,7 @@ var MahjongPub2 = class extends import_koishi3.Service {
|
|
|
468
475
|
super(ctx, "mahjongpub", true);
|
|
469
476
|
this.ctx = ctx;
|
|
470
477
|
this.config = config;
|
|
471
|
-
ctx.plugin(ContestManager);
|
|
478
|
+
ctx.plugin(ContestManager, config.manager);
|
|
472
479
|
ctx.i18n.define("zh-CN", require_zh_CN());
|
|
473
480
|
ctx.model.extend("user", {
|
|
474
481
|
"mahjongpub/bind-team": "string",
|
|
@@ -840,7 +847,8 @@ var MahjongPub2 = class extends import_koishi3.Service {
|
|
|
840
847
|
informNotbind: import_koishi3.Schema.boolean().default(false),
|
|
841
848
|
endpoint: import_koishi3.Schema.string().default("https://cdn.r-mj.com/"),
|
|
842
849
|
batchInterval: import_koishi3.Schema.natural().default(300),
|
|
843
|
-
batchCount: import_koishi3.Schema.natural().default(10)
|
|
850
|
+
batchCount: import_koishi3.Schema.natural().default(10),
|
|
851
|
+
manager: ContestManager.Config
|
|
844
852
|
});
|
|
845
853
|
})(MahjongPub2 || (MahjongPub2 = {}));
|
|
846
854
|
var index_default = MahjongPub2;
|