@chatluna/patchbay 0.1.0 → 0.1.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/package.json
CHANGED
package/patchbay.json
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
{
|
|
4
4
|
"name": "@cordisjs/plugin-cli-cordis",
|
|
5
5
|
"version": "1.0.5",
|
|
6
|
-
"description": "Stable root include id, launcher include overrides and IPC health pings"
|
|
6
|
+
"description": "Stable root include id, launcher include overrides and IPC health pings; best-effort stdio, exit on parent disconnect and a bounded exit",
|
|
7
|
+
"fixes": [
|
|
8
|
+
"ChatLunaLab/v2-mirror#99",
|
|
9
|
+
"cordiverse/cordis#294"
|
|
10
|
+
]
|
|
7
11
|
},
|
|
8
12
|
{
|
|
9
13
|
"name": "@cordisjs/plugin-database",
|
|
@@ -35,7 +39,8 @@
|
|
|
35
39
|
"version": "4.18.11",
|
|
36
40
|
"description": "Run Koishi on Cordis 4; also installed as koishi. Inject shapes are normalized by the @satorijs/core patch",
|
|
37
41
|
"fixes": [
|
|
38
|
-
"ChatLunaLab/boilerplate#12"
|
|
42
|
+
"ChatLunaLab/boilerplate#12",
|
|
43
|
+
"ChatLunaLab/v2-mirror#28"
|
|
39
44
|
],
|
|
40
45
|
"dependencies": {
|
|
41
46
|
"cordis": "^4.0.0-rc.8"
|
|
@@ -14,12 +14,40 @@ index 4362cf8..ae92999 100644
|
|
|
14
14
|
prelude?: EntryOptions[];
|
|
15
15
|
}
|
|
16
16
|
diff --git a/lib/worker/index.js b/lib/worker/index.js
|
|
17
|
-
index 91ff829..
|
|
17
|
+
index 91ff829..9c9b5ef 100644
|
|
18
18
|
--- a/lib/worker/index.js
|
|
19
19
|
+++ b/lib/worker/index.js
|
|
20
|
-
@@ -
|
|
20
|
+
@@ -17,20 +17,39 @@ __export(daemon_exports, {
|
|
21
|
+
});
|
|
22
|
+
var name = "daemon";
|
|
23
|
+
function* apply(ctx, config = {}) {
|
|
24
|
+
+ // Bounded: a stuck `exit` listener must not keep a signalled or orphaned worker alive.
|
|
25
|
+
+ function exit(signal) {
|
|
26
|
+
+ setTimeout(() => process.exit(1), 1e4).unref();
|
|
27
|
+
+ ctx.parallel("exit", signal).finally(() => process.exit());
|
|
28
|
+
+ }
|
|
29
|
+
+ __name(exit, "exit");
|
|
30
|
+
function handleSignal(signal) {
|
|
31
|
+
process.stderr.write("\x1B[2K\r");
|
|
32
|
+
if (config.autoRestart) {
|
|
33
|
+
process.send({ type: "exit" });
|
|
34
|
+
}
|
|
35
|
+
ctx.logger.info(`terminated by ${signal}`);
|
|
36
|
+
- ctx.parallel("exit", signal).finally(() => process.exit());
|
|
37
|
+
+ exit(signal);
|
|
38
|
+
}
|
|
39
|
+
__name(handleSignal, "handleSignal");
|
|
40
|
+
process.on("SIGINT", handleSignal);
|
|
41
|
+
yield () => process.off("SIGINT", handleSignal);
|
|
21
42
|
process.on("SIGTERM", handleSignal);
|
|
22
43
|
yield () => process.off("SIGTERM", handleSignal);
|
|
44
|
+
+ // The parent owns this worker: once its IPC channel closes, nothing pings, restarts or stops it.
|
|
45
|
+
+ const onDisconnect = /* @__PURE__ */ __name(() => {
|
|
46
|
+
+ ctx.logger.info("terminated by parent disconnect");
|
|
47
|
+
+ exit("SIGTERM");
|
|
48
|
+
+ }, "onDisconnect");
|
|
49
|
+
+ process.on("disconnect", onDisconnect);
|
|
50
|
+
+ yield () => process.off("disconnect", onDisconnect);
|
|
23
51
|
process.send({ type: "start", body: config });
|
|
24
52
|
+ // Health over IPC: the supervisor pings, the worker answers; no network address involved.
|
|
25
53
|
+ const onMessage = /* @__PURE__ */ __name((message) => {
|
|
@@ -30,7 +58,20 @@ index 91ff829..ec55279 100644
|
|
|
30
58
|
if (config.heartbeatInterval) {
|
|
31
59
|
const timer = setInterval(() => {
|
|
32
60
|
process.send({ type: "heartbeat" });
|
|
33
|
-
@@ -
|
|
61
|
+
@@ -43,6 +62,12 @@ __name(apply, "apply");
|
|
62
|
+
// src/worker/index.ts
|
|
63
|
+
async function start(config) {
|
|
64
|
+
const ctx = new Context();
|
|
65
|
+
+ // Output is best-effort. Without a listener, a write to a closed stdout/stderr pipe becomes an
|
|
66
|
+
+ // uncaughtException, which is logged to the same pipe and fails again, forever.
|
|
67
|
+
+ const ignore = /* @__PURE__ */ __name(() => {
|
|
68
|
+
+ }, "ignore");
|
|
69
|
+
+ process.stdout.on("error", ignore);
|
|
70
|
+
+ process.stderr.on("error", ignore);
|
|
71
|
+
process.on("uncaughtException", (error) => {
|
|
72
|
+
ctx.logger.error(error);
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
@@ -59,12 +84,22 @@ async function start(config) {
|
|
34
75
|
await ctx.loader.create(plugin);
|
|
35
76
|
}
|
|
36
77
|
await ctx.loader.create({
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
diff --git a/lib/index.cjs b/lib/index.cjs
|
|
2
|
+
index a11da83..c0f81ec 100644
|
|
3
|
+
--- a/lib/index.cjs
|
|
4
|
+
+++ b/lib/index.cjs
|
|
5
|
+
@@ -581,8 +581,21 @@ var KoishiDatabase = class {
|
|
6
|
+
}
|
|
7
|
+
async createUser(platform, pid, data) {
|
|
8
|
+
const user = await this.create("user", data);
|
|
9
|
+
- await this.create("binding", { aid: user.id, bid: user.id, pid, platform });
|
|
10
|
+
- return user;
|
|
11
|
+
+ try {
|
|
12
|
+
+ await this.create("binding", { aid: user.id, bid: user.id, pid, platform });
|
|
13
|
+
+ return user;
|
|
14
|
+
+ } catch (error) {
|
|
15
|
+
+ // patchbay: a concurrent attach bound this account first, or the binding outlived its user row.
|
|
16
|
+
+ const [binding] = await this.get("binding", { platform, pid }, ["aid"]);
|
|
17
|
+
+ if (!binding) throw error;
|
|
18
|
+
+ const [existing] = await this.get("user", { id: binding.aid });
|
|
19
|
+
+ if (existing) {
|
|
20
|
+
+ await this.remove("user", { id: user.id });
|
|
21
|
+
+ return existing;
|
|
22
|
+
+ }
|
|
23
|
+
+ await this.set("binding", { platform, pid }, { aid: user.id, bid: user.id });
|
|
24
|
+
+ return user;
|
|
25
|
+
+ }
|
|
26
|
+
}
|
|
27
|
+
async getChannel(platform, id, modifier) {
|
|
28
|
+
const data = await this.get("channel", { platform, id }, modifier);
|
|
1
29
|
diff --git a/lib/index.d.ts b/lib/index.d.ts
|
|
2
30
|
index b0e0826..004cff1 100644
|
|
3
31
|
--- a/lib/index.d.ts
|
|
@@ -264,7 +292,7 @@ index b0e0826..004cff1 100644
|
|
|
264
292
|
+export * from '@cordisjs/plugin-database';
|
|
265
293
|
export { version };
|
|
266
294
|
diff --git a/lib/index.mjs b/lib/index.mjs
|
|
267
|
-
index b99cd02..
|
|
295
|
+
index b99cd02..cbac35c 100644
|
|
268
296
|
--- a/lib/index.mjs
|
|
269
297
|
+++ b/lib/index.mjs
|
|
270
298
|
@@ -2,16 +2,120 @@ var __defProp = Object.defineProperty;
|
|
@@ -465,7 +493,31 @@ index b99cd02..2d446d8 100644
|
|
|
465
493
|
getUser: "database.getUser",
|
|
466
494
|
setUser: "database.setUser",
|
|
467
495
|
createUser: "database.createUser",
|
|
468
|
-
@@ -
|
|
496
|
+
@@ -517,8 +624,21 @@ var KoishiDatabase = class {
|
|
497
|
+
}
|
|
498
|
+
async createUser(platform, pid, data) {
|
|
499
|
+
const user = await this.create("user", data);
|
|
500
|
+
- await this.create("binding", { aid: user.id, bid: user.id, pid, platform });
|
|
501
|
+
- return user;
|
|
502
|
+
+ try {
|
|
503
|
+
+ await this.create("binding", { aid: user.id, bid: user.id, pid, platform });
|
|
504
|
+
+ return user;
|
|
505
|
+
+ } catch (error) {
|
|
506
|
+
+ // patchbay: a concurrent attach bound this account first, or the binding outlived its user row.
|
|
507
|
+
+ const [binding] = await this.get("binding", { platform, pid }, ["aid"]);
|
|
508
|
+
+ if (!binding) throw error;
|
|
509
|
+
+ const [existing] = await this.get("user", { id: binding.aid });
|
|
510
|
+
+ if (existing) {
|
|
511
|
+
+ await this.remove("user", { id: user.id });
|
|
512
|
+
+ return existing;
|
|
513
|
+
+ }
|
|
514
|
+
+ await this.set("binding", { platform, pid }, { aid: user.id, bid: user.id });
|
|
515
|
+
+ return user;
|
|
516
|
+
+ }
|
|
517
|
+
}
|
|
518
|
+
async getChannel(platform, id, modifier) {
|
|
519
|
+
const data = await this.get("channel", { platform, id }, modifier);
|
|
520
|
+
@@ -607,37 +727,29 @@ var Next;
|
|
469
521
|
Next2.compose = compose;
|
|
470
522
|
__name(compose, "compose");
|
|
471
523
|
})(Next || (Next = {}));
|
|
@@ -514,7 +566,7 @@ index b99cd02..2d446d8 100644
|
|
|
514
566
|
let ms = +attrs.value;
|
|
515
567
|
for (let index = 0; index < 3; index++) {
|
|
516
568
|
const major = Time[units[index]];
|
|
517
|
-
@@ -653,6 +
|
|
569
|
+
@@ -653,6 +765,21 @@ var Processor = class {
|
|
518
570
|
}
|
|
519
571
|
return Math.round(ms / Time.second) + " " + session.text("general.second");
|
|
520
572
|
}, { session: true });
|
|
@@ -536,7 +588,7 @@ index b99cd02..2d446d8 100644
|
|
|
536
588
|
ctx.before("attach", (session) => {
|
|
537
589
|
for (const matcher of this._matchers) {
|
|
538
590
|
this._executeMatcher(session, matcher);
|
|
539
|
-
@@ -663,6 +
|
|
591
|
+
@@ -663,6 +790,8 @@ var Processor = class {
|
|
540
592
|
static {
|
|
541
593
|
__name(this, "Processor");
|
|
542
594
|
}
|
|
@@ -545,7 +597,7 @@ index b99cd02..2d446d8 100644
|
|
|
545
597
|
_hooks = [];
|
|
546
598
|
_sessions = /* @__PURE__ */ Object.create(null);
|
|
547
599
|
_matchers = /* @__PURE__ */ new Set();
|
|
548
|
-
@@ -670,12 +
|
|
600
|
+
@@ -670,12 +799,12 @@ var Processor = class {
|
|
549
601
|
if (typeof options !== "object") {
|
|
550
602
|
options = { prepend: options };
|
|
551
603
|
}
|
|
@@ -560,7 +612,7 @@ index b99cd02..2d446d8 100644
|
|
|
560
612
|
return this._matchers.delete(matcher);
|
|
561
613
|
});
|
|
562
614
|
}
|
|
563
|
-
@@ -683,7 +
|
|
615
|
+
@@ -683,7 +812,7 @@ var Processor = class {
|
|
564
616
|
const { stripped, quote } = session;
|
|
565
617
|
const { appel, context, i18n, regex, fuzzy, pattern, response } = matcher;
|
|
566
618
|
if ((appel || stripped.hasAt) && !stripped.appel) return;
|
|
@@ -569,7 +621,7 @@ index b99cd02..2d446d8 100644
|
|
|
569
621
|
let content = stripped.content;
|
|
570
622
|
if (quote?.content) content += " " + quote.content;
|
|
571
623
|
let params = null;
|
|
572
|
-
@@ -724,7 +
|
|
624
|
+
@@ -724,7 +853,7 @@ var Processor = class {
|
|
573
625
|
}
|
|
574
626
|
async attach(session, next) {
|
|
575
627
|
this.ctx.emit(session, "before-attach", session);
|
|
@@ -578,7 +630,7 @@ index b99cd02..2d446d8 100644
|
|
|
578
630
|
if (!session.isDirect) {
|
|
579
631
|
const channelFields = /* @__PURE__ */ new Set(["flag", "assignee", "guildId", "permissions", "locales"]);
|
|
580
632
|
this.ctx.emit("before-attach-channel", session, channelFields);
|
|
581
|
-
@@ -747,7 +
|
|
633
|
+
@@ -747,7 +876,7 @@ var Processor = class {
|
|
582
634
|
async _handleMessage(session) {
|
|
583
635
|
if (session.selfId === session.userId) return;
|
|
584
636
|
this._sessions[session.id] = session;
|
|
@@ -587,7 +639,7 @@ index b99cd02..2d446d8 100644
|
|
|
587
639
|
let index = 0;
|
|
588
640
|
const next = /* @__PURE__ */ __name(async (callback) => {
|
|
589
641
|
try {
|
|
590
|
-
@@ -778,7 +
|
|
642
|
+
@@ -778,7 +907,14 @@ ${stack}`);
|
|
591
643
|
await session.user?.$update();
|
|
592
644
|
await session.channel?.$update();
|
|
593
645
|
await session.guild?.$update();
|
|
@@ -603,7 +655,7 @@ index b99cd02..2d446d8 100644
|
|
|
603
655
|
}
|
|
604
656
|
}
|
|
605
657
|
};
|
|
606
|
-
@@ -843,7 +
|
|
658
|
+
@@ -843,7 +979,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
607
659
|
ctx.$commander._commandList.push(this);
|
|
608
660
|
}
|
|
609
661
|
get caller() {
|
|
@@ -612,7 +664,7 @@ index b99cd02..2d446d8 100644
|
|
|
612
664
|
}
|
|
613
665
|
get displayName() {
|
|
614
666
|
return Object.keys(this._aliases)[0];
|
|
615
|
-
@@ -971,7 +
|
|
667
|
+
@@ -971,7 +1107,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
616
668
|
return this;
|
|
617
669
|
}
|
|
618
670
|
match(session) {
|
|
@@ -621,7 +673,7 @@ index b99cd02..2d446d8 100644
|
|
|
621
673
|
}
|
|
622
674
|
check(callback, append = false) {
|
|
623
675
|
return this.before(callback, append);
|
|
624
|
-
@@ -982,7 +
|
|
676
|
+
@@ -982,7 +1118,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
625
677
|
} else {
|
|
626
678
|
this._checkers.unshift(callback);
|
|
627
679
|
}
|
|
@@ -630,7 +682,7 @@ index b99cd02..2d446d8 100644
|
|
|
630
682
|
return this;
|
|
631
683
|
}
|
|
632
684
|
action(callback, prepend = false) {
|
|
633
|
-
@@ -991,7 +
|
|
685
|
+
@@ -991,7 +1127,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
634
686
|
} else {
|
|
635
687
|
this._actions.push(callback);
|
|
636
688
|
}
|
|
@@ -639,7 +691,7 @@ index b99cd02..2d446d8 100644
|
|
|
639
691
|
return this;
|
|
640
692
|
}
|
|
641
693
|
/** @deprecated */
|
|
642
|
-
@@ -1095,7 +
|
|
694
|
+
@@ -1095,7 +1231,9 @@ __name(toStringType, "toStringType");
|
|
643
695
|
// src/command/validate.ts
|
|
644
696
|
import { isNullable as isNullable2 } from "cosmokit";
|
|
645
697
|
function validate(ctx) {
|
|
@@ -650,7 +702,7 @@ index b99cd02..2d446d8 100644
|
|
|
650
702
|
depends: /* @__PURE__ */ __name(({ name }) => {
|
|
651
703
|
const command = ctx.$commander.get(name);
|
|
652
704
|
if (!command) return;
|
|
653
|
-
@@ -1110,7 +
|
|
705
|
+
@@ -1110,7 +1248,7 @@ function validate(ctx) {
|
|
654
706
|
return ctx.$commander._commandList.map((command) => `command:${command.name}`);
|
|
655
707
|
}, "list")
|
|
656
708
|
});
|
|
@@ -659,7 +711,7 @@ index b99cd02..2d446d8 100644
|
|
|
659
711
|
depends: /* @__PURE__ */ __name(({ name, name2 }) => {
|
|
660
712
|
return ctx.$commander.get(name)?._options[name2]?.dependencies;
|
|
661
713
|
}, "depends"),
|
|
662
|
-
@@ -1130,13 +
|
|
714
|
+
@@ -1130,13 +1268,13 @@ function validate(ctx) {
|
|
663
715
|
return command.config.showWarning ? session.text(message, param) : "";
|
|
664
716
|
}
|
|
665
717
|
__name(sendHint, "sendHint");
|
|
@@ -676,7 +728,7 @@ index b99cd02..2d446d8 100644
|
|
|
676
728
|
return sendHint("internal.low-authority");
|
|
677
729
|
}
|
|
678
730
|
}, true);
|
|
679
|
-
@@ -1182,7 +
|
|
731
|
+
@@ -1182,7 +1320,7 @@ var Commander = class {
|
|
680
732
|
constructor(ctx, config = {}) {
|
|
681
733
|
this.ctx = ctx;
|
|
682
734
|
this.config = config;
|
|
@@ -685,7 +737,7 @@ index b99cd02..2d446d8 100644
|
|
|
685
737
|
ctx.plugin(validate);
|
|
686
738
|
ctx.before("parse", (content, session) => {
|
|
687
739
|
const { isDirect, stripped: { prefix, appel } } = session;
|
|
688
|
-
@@ -1255,7 +
|
|
740
|
+
@@ -1255,7 +1393,7 @@ var Commander = class {
|
|
689
741
|
permissions: Schema2.array(String).role("perms").default(["authority:0"]).description("权限继承。"),
|
|
690
742
|
dependencies: Schema2.array(String).role("perms").description("权限依赖。")
|
|
691
743
|
}), 1e3);
|
|
@@ -694,7 +746,7 @@ index b99cd02..2d446d8 100644
|
|
|
694
746
|
const bots = ctx.bots.filter((v) => v.status === Universal3.Status.ONLINE && v.updateCommands);
|
|
695
747
|
bots.forEach((bot) => this.updateCommands(bot));
|
|
696
748
|
});
|
|
697
|
-
@@ -1334,6 +
|
|
749
|
+
@@ -1334,6 +1472,8 @@ var Commander = class {
|
|
698
750
|
static {
|
|
699
751
|
__name(this, "Commander");
|
|
700
752
|
}
|
|
@@ -703,7 +755,7 @@ index b99cd02..2d446d8 100644
|
|
|
703
755
|
_commandList = [];
|
|
704
756
|
defineElementDomain(name, key = name, type = name) {
|
|
705
757
|
this.domain(name, (source, session) => {
|
|
706
|
-
@@ -1456,13 +
|
|
758
|
+
@@ -1456,13 +1596,14 @@ var Commander = class {
|
|
707
759
|
});
|
|
708
760
|
Object.assign(parent.config, config);
|
|
709
761
|
created.forEach((command) => this.ctx.emit("command-added", command));
|
|
@@ -721,7 +773,7 @@ index b99cd02..2d446d8 100644
|
|
|
721
773
|
return this.ctx.set(service, { transform, ...options });
|
|
722
774
|
}
|
|
723
775
|
resolveDomain(type) {
|
|
724
|
-
@@ -1570,6 +
|
|
776
|
+
@@ -1570,6 +1711,8 @@ var I18n = class {
|
|
725
777
|
static {
|
|
726
778
|
__name(this, "I18n");
|
|
727
779
|
}
|
|
@@ -730,7 +782,7 @@ index b99cd02..2d446d8 100644
|
|
|
730
782
|
_data = {};
|
|
731
783
|
_presets = {};
|
|
732
784
|
locales;
|
|
733
|
-
@@ -1613,7 +
|
|
785
|
+
@@ -1613,7 +1756,7 @@ var I18n = class {
|
|
734
786
|
const dict = this._data[locale] ||= {};
|
|
735
787
|
const paths = [...typeof args[0] === "string" ? this.set(locale, args[0] + ".", args[1]) : this.set(locale, "", args[0])];
|
|
736
788
|
this.ctx.emit("internal/i18n");
|
|
@@ -739,7 +791,7 @@ index b99cd02..2d446d8 100644
|
|
|
739
791
|
for (const path2 of paths) {
|
|
740
792
|
delete dict[path2];
|
|
741
793
|
}
|
|
742
|
-
@@ -1680,7 +
|
|
794
|
+
@@ -1680,7 +1823,7 @@ var I18n = class {
|
|
743
795
|
import { observe } from "@koishijs/utils";
|
|
744
796
|
import { isNullable as isNullable4, makeArray as makeArray2 } from "cosmokit";
|
|
745
797
|
import { h as h5, Logger as Logger3 } from "@satorijs/core";
|
|
@@ -748,7 +800,7 @@ index b99cd02..2d446d8 100644
|
|
|
748
800
|
var logger3 = new Logger3("session");
|
|
749
801
|
function collectFields(argv, collectors, fields) {
|
|
750
802
|
for (const collector of collectors) {
|
|
751
|
-
@@ -1700,7 +
|
|
803
|
+
@@ -1700,7 +1843,8 @@ var KoishiSession = class {
|
|
752
804
|
__name(this, "KoishiSession");
|
|
753
805
|
}
|
|
754
806
|
constructor(ctx) {
|
|
@@ -758,7 +810,7 @@ index b99cd02..2d446d8 100644
|
|
|
758
810
|
resolve: "session.resolve",
|
|
759
811
|
stripped: "session.stripped",
|
|
760
812
|
username: "session.username",
|
|
761
|
-
@@ -1969,7 +
|
|
813
|
+
@@ -1969,7 +2113,7 @@ var KoishiSession = class {
|
|
762
814
|
}
|
|
763
815
|
}
|
|
764
816
|
const { command } = argv;
|
|
@@ -767,7 +819,7 @@ index b99cd02..2d446d8 100644
|
|
|
767
819
|
if (this.app.database) {
|
|
768
820
|
if (!this.isDirect) {
|
|
769
821
|
await this.observeChannel(this.collect("channel", argv, /* @__PURE__ */ new Set(["permissions", "locales"])));
|
|
770
|
-
@@ -2058,8 +
|
|
822
|
+
@@ -2058,8 +2202,7 @@ var logger4 = new Logger4("app");
|
|
771
823
|
var Permissions = class {
|
|
772
824
|
constructor(ctx) {
|
|
773
825
|
this.ctx = ctx;
|
|
@@ -777,7 +829,7 @@ index b99cd02..2d446d8 100644
|
|
|
777
829
|
this.define("authority:(value)", {
|
|
778
830
|
check: /* @__PURE__ */ __name(({ value }, { user }) => {
|
|
779
831
|
return !user || user.authority >= +value;
|
|
780
|
-
@@ -2076,6 +
|
|
832
|
+
@@ -2076,6 +2219,8 @@ var Permissions = class {
|
|
781
833
|
static {
|
|
782
834
|
__name(this, "Permissions");
|
|
783
835
|
}
|
|
@@ -786,7 +838,7 @@ index b99cd02..2d446d8 100644
|
|
|
786
838
|
store = [];
|
|
787
839
|
define(pattern, options) {
|
|
788
840
|
const entry = {
|
|
789
|
-
@@ -2167,7 +
|
|
841
|
+
@@ -2167,7 +2312,8 @@ var KoishiBot = class {
|
|
790
842
|
__name(this, "KoishiBot");
|
|
791
843
|
}
|
|
792
844
|
constructor(ctx) {
|
|
@@ -796,7 +848,7 @@ index b99cd02..2d446d8 100644
|
|
|
796
848
|
getGuildMemberMap: "bot.getGuildMemberMap",
|
|
797
849
|
broadcast: "bot.broadcast"
|
|
798
850
|
});
|
|
799
|
-
@@ -2238,9 +
|
|
851
|
+
@@ -2238,9 +2384,11 @@ var SchemaService = class {
|
|
800
852
|
static {
|
|
801
853
|
__name(this, "SchemaService");
|
|
802
854
|
}
|
|
@@ -809,7 +861,7 @@ index b99cd02..2d446d8 100644
|
|
|
809
861
|
const target = this.get(name);
|
|
810
862
|
const index = target.list.findIndex((a) => a[kSchemaOrder] < order);
|
|
811
863
|
schema[kSchemaOrder] = order;
|
|
812
|
-
@@ -2250,7 +
|
|
864
|
+
@@ -2250,7 +2398,7 @@ var SchemaService = class {
|
|
813
865
|
target.list.push(schema);
|
|
814
866
|
}
|
|
815
867
|
this.ctx.emit("internal/schema", name);
|
|
@@ -818,7 +870,7 @@ index b99cd02..2d446d8 100644
|
|
|
818
870
|
remove3(target.list, schema);
|
|
819
871
|
this.ctx.emit("internal/schema", name);
|
|
820
872
|
});
|
|
821
|
-
@@ -2259,10 +
|
|
873
|
+
@@ -2259,10 +2407,10 @@ var SchemaService = class {
|
|
822
874
|
return this._data[name] ||= Schema4.intersect([]);
|
|
823
875
|
}
|
|
824
876
|
set(name, schema) {
|
|
@@ -831,7 +883,7 @@ index b99cd02..2d446d8 100644
|
|
|
831
883
|
delete this._data[name];
|
|
832
884
|
this.ctx.emit("internal/schema", name);
|
|
833
885
|
});
|
|
834
|
-
@@ -2272,6 +
|
|
886
|
+
@@ -2272,6 +2420,95 @@ var SchemaService = class {
|
|
835
887
|
// src/context.ts
|
|
836
888
|
import { Adapter as Adapter2, Bot as Bot3, Element, h as h6, HTTP as HTTP2, Logger as Logger5, MessageEncoder, Messenger, Quester, Schema as Schema6, segment, Universal as Universal5, z } from "@satorijs/core";
|
|
837
889
|
import { resolveConfig } from "cordis";
|
|
@@ -927,7 +979,7 @@ index b99cd02..2d446d8 100644
|
|
|
927
979
|
var Context = class extends satori.Context {
|
|
928
980
|
static {
|
|
929
981
|
__name(this, "Context");
|
|
930
|
-
@@ -2279,31 +
|
|
982
|
+
@@ -2279,31 +2516,8 @@ var Context = class extends satori.Context {
|
|
931
983
|
static shadow = /* @__PURE__ */ Symbol.for("session.shadow");
|
|
932
984
|
constructor(config = {}) {
|
|
933
985
|
super(config);
|
|
@@ -961,7 +1013,7 @@ index b99cd02..2d446d8 100644
|
|
|
961
1013
|
}
|
|
962
1014
|
/** @deprecated use `ctx.root` instead */
|
|
963
1015
|
get app() {
|
|
964
|
-
@@ -2313,25 +
|
|
1016
|
+
@@ -2313,25 +2527,6 @@ var Context = class extends satori.Context {
|
|
965
1017
|
get options() {
|
|
966
1018
|
return this.root.config;
|
|
967
1019
|
}
|
|
@@ -987,7 +1039,7 @@ index b99cd02..2d446d8 100644
|
|
|
987
1039
|
before(name, listener, append = false) {
|
|
988
1040
|
const seg = name.split("/");
|
|
989
1041
|
seg[seg.length - 1] = "before-" + seg[seg.length - 1];
|
|
990
|
-
@@ -2339,19 +
|
|
1042
|
+
@@ -2339,19 +2534,36 @@ var Context = class extends satori.Context {
|
|
991
1043
|
}
|
|
992
1044
|
};
|
|
993
1045
|
var Koishi = class extends cordis.Service {
|
|
@@ -1031,7 +1083,7 @@ index b99cd02..2d446d8 100644
|
|
|
1031
1083
|
};
|
|
1032
1084
|
((Context3) => {
|
|
1033
1085
|
Context3.Config = Schema5.intersect([
|
|
1034
|
-
@@ -2399,12 +
|
|
1086
|
+
@@ -2399,12 +2611,15 @@ var Service3 = class extends satori.Service {
|
|
1035
1087
|
this.ctx = new Context();
|
|
1036
1088
|
}
|
|
1037
1089
|
};
|
|
@@ -1047,7 +1099,7 @@ index b99cd02..2d446d8 100644
|
|
|
1047
1099
|
Context as App,
|
|
1048
1100
|
Argv,
|
|
1049
1101
|
Bot3 as Bot,
|
|
1050
|
-
@@ -2426,6 +
|
|
1102
|
+
@@ -2426,6 +2641,7 @@ export {
|
|
1051
1103
|
Schema6 as Schema,
|
|
1052
1104
|
SchemaService,
|
|
1053
1105
|
Service3 as Service,
|