@chatluna/patchbay 0.1.6 → 0.1.8
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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
9
|
"name": "@cordisjs/plugin-database",
|
|
10
|
-
"version": "4.
|
|
10
|
+
"version": "4.2.0",
|
|
11
11
|
"description": "Prepare tables extended while the driver was still starting; also installed as minato"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"name": "@cordisjs/unyaml",
|
|
34
|
-
"version": "
|
|
34
|
+
"version": "3.0.0",
|
|
35
35
|
"description": "Register the Vite YAML plugin through rolldownOptions instead of the retired esbuildOptions"
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -292,10 +292,10 @@ index b0e0826..004cff1 100644
|
|
|
292
292
|
+export * from '@cordisjs/plugin-database';
|
|
293
293
|
export { version };
|
|
294
294
|
diff --git a/lib/index.mjs b/lib/index.mjs
|
|
295
|
-
index b99cd02..
|
|
295
|
+
index b99cd02..095a3eb 100644
|
|
296
296
|
--- a/lib/index.mjs
|
|
297
297
|
+++ b/lib/index.mjs
|
|
298
|
-
@@ -2,16 +2,
|
|
298
|
+
@@ -2,16 +2,124 @@ var __defProp = Object.defineProperty;
|
|
299
299
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
300
300
|
|
|
301
301
|
// src/index.ts
|
|
@@ -356,8 +356,12 @@ index b99cd02..ddbf1bf 100644
|
|
|
356
356
|
+// chatluna: Cordis 4 bridge. Cordis 3 symbols/services that Koishi relies on are
|
|
357
357
|
+// re-created here; the Context class itself is patched further below.
|
|
358
358
|
+const kContextCurrent = Symbol.for("koishi.current");
|
|
359
|
+
+// Koishi's session predicate per context. Not `Context.filter`: Cordis 4 calls that on the event's thisArg with the
|
|
360
|
+
+// hook's context, so a filtered context emitting (as in `ctx.on`, which bails `internal/listener` with itself)
|
|
361
|
+
+// would feed a Context into a session predicate. Sessions bridge to it through `Session.prototype[Context.filter]`.
|
|
362
|
+
+const kFilter = Symbol.for("koishi.filter");
|
|
359
363
|
+function kFilterHooks(hooks, thisArg) {
|
|
360
|
-
+ return (hooks || []).filter((hook) => hook.global || !hook.ctx?.[
|
|
364
|
+
+ return (hooks || []).filter((hook) => hook.global || !hook.ctx?.[kFilter] || hook.ctx[kFilter](thisArg));
|
|
361
365
|
+}
|
|
362
366
|
+function kRegister(ctx, hooks, name, callback, options = {}) {
|
|
363
367
|
+ const hook = { ctx, callback, prepend: options.prepend === true };
|
|
@@ -420,7 +424,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
420
424
|
|
|
421
425
|
// src/filter.ts
|
|
422
426
|
import { defineProperty } from "cosmokit";
|
|
423
|
-
@@ -24,35 +
|
|
427
|
+
@@ -24,35 +132,38 @@ __name(property, "property");
|
|
424
428
|
var FilterService = class {
|
|
425
429
|
constructor(ctx) {
|
|
426
430
|
this.ctx = ctx;
|
|
@@ -431,11 +435,11 @@ index b99cd02..ddbf1bf 100644
|
|
|
431
435
|
- runtime.ctx.filter = (session) => {
|
|
432
436
|
- return runtime.children.some((p) => p.ctx.filter(session));
|
|
433
437
|
+ defineProperty(this, kContextCurrent, ctx);
|
|
434
|
-
+ ctx.root[
|
|
438
|
+
+ ctx.root[kFilter] ??= () => true;
|
|
435
439
|
+ ctx.on("internal/plugin", (fiber) => {
|
|
436
440
|
+ if (!fiber.uid) return;
|
|
437
|
-
+ const parentFilter = fiber.ctx[
|
|
438
|
-
+ fiber.ctx[
|
|
441
|
+
+ const parentFilter = fiber.ctx[kFilter] ?? (() => true);
|
|
442
|
+
+ fiber.ctx[kFilter] = (session) => {
|
|
439
443
|
+ return parentFilter(session);
|
|
440
444
|
};
|
|
441
445
|
});
|
|
@@ -447,33 +451,33 @@ index b99cd02..ddbf1bf 100644
|
|
|
447
451
|
+ [cordisSymbols.tracker] = { property: "ctx" };
|
|
448
452
|
any() {
|
|
449
453
|
- return this.ctx.extend({ filter: /* @__PURE__ */ __name(() => true, "filter") });
|
|
450
|
-
+ return this.ctx.extend({ [
|
|
454
|
+
+ return this.ctx.extend({ [kFilter]: () => true });
|
|
451
455
|
}
|
|
452
456
|
never() {
|
|
453
457
|
- return this.ctx.extend({ filter: /* @__PURE__ */ __name(() => false, "filter") });
|
|
454
|
-
+ return this.ctx.extend({ [
|
|
458
|
+
+ return this.ctx.extend({ [kFilter]: () => false });
|
|
455
459
|
}
|
|
456
460
|
union(arg) {
|
|
457
461
|
- const filter2 = typeof arg === "function" ? arg : arg.filter;
|
|
458
462
|
- return this.ctx.extend({ filter: /* @__PURE__ */ __name((s) => this.ctx.filter(s) || filter2(s), "filter") });
|
|
459
|
-
+ const filter2 = typeof arg === "function" ? arg : arg[
|
|
460
|
-
+ return this.ctx.extend({ [
|
|
463
|
+
+ const filter2 = typeof arg === "function" ? arg : arg[kFilter];
|
|
464
|
+
+ return this.ctx.extend({ [kFilter]: (s) => this.ctx[kFilter](s) || filter2(s) });
|
|
461
465
|
}
|
|
462
466
|
intersect(arg) {
|
|
463
467
|
- const filter2 = typeof arg === "function" ? arg : arg.filter;
|
|
464
468
|
- return this.ctx.extend({ filter: /* @__PURE__ */ __name((s) => this.ctx.filter(s) && filter2(s), "filter") });
|
|
465
|
-
+ const filter2 = typeof arg === "function" ? arg : arg[
|
|
466
|
-
+ return this.ctx.extend({ [
|
|
469
|
+
+ const filter2 = typeof arg === "function" ? arg : arg[kFilter];
|
|
470
|
+
+ return this.ctx.extend({ [kFilter]: (s) => this.ctx[kFilter](s) && filter2(s) });
|
|
467
471
|
}
|
|
468
472
|
exclude(arg) {
|
|
469
473
|
- const filter2 = typeof arg === "function" ? arg : arg.filter;
|
|
470
474
|
- return this.ctx.extend({ filter: /* @__PURE__ */ __name((s) => this.ctx.filter(s) && !filter2(s), "filter") });
|
|
471
|
-
+ const filter2 = typeof arg === "function" ? arg : arg[
|
|
472
|
-
+ return this.ctx.extend({ [
|
|
475
|
+
+ const filter2 = typeof arg === "function" ? arg : arg[kFilter];
|
|
476
|
+
+ return this.ctx.extend({ [kFilter]: (s) => this.ctx[kFilter](s) && !filter2(s) });
|
|
473
477
|
}
|
|
474
478
|
user(...values) {
|
|
475
479
|
return property(this.ctx, "userId", ...values);
|
|
476
|
-
@@ -422,8 +
|
|
480
|
+
@@ -422,8 +533,8 @@ var Argv;
|
|
477
481
|
})(Argv || (Argv = {}));
|
|
478
482
|
|
|
479
483
|
// src/middleware.ts
|
|
@@ -484,7 +488,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
484
488
|
import { h as h2 } from "@satorijs/core";
|
|
485
489
|
|
|
486
490
|
// src/database.ts
|
|
487
|
-
@@ -446,7 +
|
|
491
|
+
@@ -446,7 +557,7 @@ var Channel;
|
|
488
492
|
var KoishiDatabase = class {
|
|
489
493
|
constructor(ctx) {
|
|
490
494
|
this.ctx = ctx;
|
|
@@ -493,7 +497,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
493
497
|
getUser: "database.getUser",
|
|
494
498
|
setUser: "database.setUser",
|
|
495
499
|
createUser: "database.createUser",
|
|
496
|
-
@@ -517,8 +
|
|
500
|
+
@@ -517,8 +628,21 @@ var KoishiDatabase = class {
|
|
497
501
|
}
|
|
498
502
|
async createUser(platform, pid, data) {
|
|
499
503
|
const user = await this.create("user", data);
|
|
@@ -517,7 +521,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
517
521
|
}
|
|
518
522
|
async getChannel(platform, id, modifier) {
|
|
519
523
|
const data = await this.get("channel", { platform, id }, modifier);
|
|
520
|
-
@@ -607,37 +
|
|
524
|
+
@@ -607,37 +731,29 @@ var Next;
|
|
521
525
|
Next2.compose = compose;
|
|
522
526
|
__name(compose, "compose");
|
|
523
527
|
})(Next || (Next = {}));
|
|
@@ -566,7 +570,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
566
570
|
let ms = +attrs.value;
|
|
567
571
|
for (let index = 0; index < 3; index++) {
|
|
568
572
|
const major = Time[units[index]];
|
|
569
|
-
@@ -653,6 +
|
|
573
|
+
@@ -653,6 +769,21 @@ var Processor = class {
|
|
570
574
|
}
|
|
571
575
|
return Math.round(ms / Time.second) + " " + session.text("general.second");
|
|
572
576
|
}, { session: true });
|
|
@@ -588,7 +592,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
588
592
|
ctx.before("attach", (session) => {
|
|
589
593
|
for (const matcher of this._matchers) {
|
|
590
594
|
this._executeMatcher(session, matcher);
|
|
591
|
-
@@ -663,6 +
|
|
595
|
+
@@ -663,6 +794,8 @@ var Processor = class {
|
|
592
596
|
static {
|
|
593
597
|
__name(this, "Processor");
|
|
594
598
|
}
|
|
@@ -597,7 +601,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
597
601
|
_hooks = [];
|
|
598
602
|
_sessions = /* @__PURE__ */ Object.create(null);
|
|
599
603
|
_matchers = /* @__PURE__ */ new Set();
|
|
600
|
-
@@ -670,12 +
|
|
604
|
+
@@ -670,12 +803,12 @@ var Processor = class {
|
|
601
605
|
if (typeof options !== "object") {
|
|
602
606
|
options = { prepend: options };
|
|
603
607
|
}
|
|
@@ -612,16 +616,16 @@ index b99cd02..ddbf1bf 100644
|
|
|
612
616
|
return this._matchers.delete(matcher);
|
|
613
617
|
});
|
|
614
618
|
}
|
|
615
|
-
@@ -683,7 +
|
|
619
|
+
@@ -683,7 +816,7 @@ var Processor = class {
|
|
616
620
|
const { stripped, quote } = session;
|
|
617
621
|
const { appel, context, i18n, regex, fuzzy, pattern, response } = matcher;
|
|
618
622
|
if ((appel || stripped.hasAt) && !stripped.appel) return;
|
|
619
623
|
- if (!context.filter(session)) return;
|
|
620
|
-
+ if (!(context[
|
|
624
|
+
+ if (!(context[kFilter]?.(session) ?? true)) return;
|
|
621
625
|
let content = stripped.content;
|
|
622
626
|
if (quote?.content) content += " " + quote.content;
|
|
623
627
|
let params = null;
|
|
624
|
-
@@ -724,7 +
|
|
628
|
+
@@ -724,7 +857,7 @@ var Processor = class {
|
|
625
629
|
}
|
|
626
630
|
async attach(session, next) {
|
|
627
631
|
this.ctx.emit(session, "before-attach", session);
|
|
@@ -630,7 +634,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
630
634
|
if (!session.isDirect) {
|
|
631
635
|
const channelFields = /* @__PURE__ */ new Set(["flag", "assignee", "guildId", "permissions", "locales"]);
|
|
632
636
|
this.ctx.emit("before-attach-channel", session, channelFields);
|
|
633
|
-
@@ -747,7 +
|
|
637
|
+
@@ -747,7 +880,7 @@ var Processor = class {
|
|
634
638
|
async _handleMessage(session) {
|
|
635
639
|
if (session.selfId === session.userId) return;
|
|
636
640
|
this._sessions[session.id] = session;
|
|
@@ -639,7 +643,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
639
643
|
let index = 0;
|
|
640
644
|
const next = /* @__PURE__ */ __name(async (callback) => {
|
|
641
645
|
try {
|
|
642
|
-
@@ -778,7 +
|
|
646
|
+
@@ -778,7 +911,14 @@ ${stack}`);
|
|
643
647
|
await session.user?.$update();
|
|
644
648
|
await session.channel?.$update();
|
|
645
649
|
await session.guild?.$update();
|
|
@@ -655,7 +659,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
655
659
|
}
|
|
656
660
|
}
|
|
657
661
|
};
|
|
658
|
-
@@ -843,7 +
|
|
662
|
+
@@ -843,7 +983,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
659
663
|
ctx.$commander._commandList.push(this);
|
|
660
664
|
}
|
|
661
665
|
get caller() {
|
|
@@ -664,16 +668,16 @@ index b99cd02..ddbf1bf 100644
|
|
|
664
668
|
}
|
|
665
669
|
get displayName() {
|
|
666
670
|
return Object.keys(this._aliases)[0];
|
|
667
|
-
@@ -971,7 +
|
|
671
|
+
@@ -971,7 +1111,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
668
672
|
return this;
|
|
669
673
|
}
|
|
670
674
|
match(session) {
|
|
671
675
|
- return this.ctx.filter(session);
|
|
672
|
-
+ return this.ctx[
|
|
676
|
+
+ return this.ctx[kFilter]?.(session) ?? true;
|
|
673
677
|
}
|
|
674
678
|
check(callback, append = false) {
|
|
675
679
|
return this.before(callback, append);
|
|
676
|
-
@@ -982,7 +
|
|
680
|
+
@@ -982,7 +1122,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
677
681
|
} else {
|
|
678
682
|
this._checkers.unshift(callback);
|
|
679
683
|
}
|
|
@@ -682,7 +686,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
682
686
|
return this;
|
|
683
687
|
}
|
|
684
688
|
action(callback, prepend = false) {
|
|
685
|
-
@@ -991,7 +
|
|
689
|
+
@@ -991,7 +1131,7 @@ var Command = class _Command extends Argv.CommandBase {
|
|
686
690
|
} else {
|
|
687
691
|
this._actions.push(callback);
|
|
688
692
|
}
|
|
@@ -691,7 +695,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
691
695
|
return this;
|
|
692
696
|
}
|
|
693
697
|
/** @deprecated */
|
|
694
|
-
@@ -1095,6 +
|
|
698
|
+
@@ -1095,6 +1235,43 @@ __name(toStringType, "toStringType");
|
|
695
699
|
// src/command/validate.ts
|
|
696
700
|
import { isNullable as isNullable2 } from "cosmokit";
|
|
697
701
|
function validate(ctx) {
|
|
@@ -735,7 +739,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
735
739
|
ctx.permissions.define("command:(name)", {
|
|
736
740
|
depends: /* @__PURE__ */ __name(({ name }) => {
|
|
737
741
|
const command = ctx.$commander.get(name);
|
|
738
|
-
@@ -1130,50 +
|
|
742
|
+
@@ -1130,50 +1307,19 @@ function validate(ctx) {
|
|
739
743
|
return command.config.showWarning ? session.text(message, param) : "";
|
|
740
744
|
}
|
|
741
745
|
__name(sendHint, "sendHint");
|
|
@@ -792,7 +796,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
792
796
|
|
|
793
797
|
// src/command/index.ts
|
|
794
798
|
var isArray = Array.isArray;
|
|
795
|
-
@@ -1182,7 +
|
|
799
|
+
@@ -1182,7 +1328,7 @@ var Commander = class {
|
|
796
800
|
constructor(ctx, config = {}) {
|
|
797
801
|
this.ctx = ctx;
|
|
798
802
|
this.config = config;
|
|
@@ -801,7 +805,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
801
805
|
ctx.plugin(validate);
|
|
802
806
|
ctx.before("parse", (content, session) => {
|
|
803
807
|
const { isDirect, stripped: { prefix, appel } } = session;
|
|
804
|
-
@@ -1255,7 +
|
|
808
|
+
@@ -1255,7 +1401,7 @@ var Commander = class {
|
|
805
809
|
permissions: Schema2.array(String).role("perms").default(["authority:0"]).description("权限继承。"),
|
|
806
810
|
dependencies: Schema2.array(String).role("perms").description("权限依赖。")
|
|
807
811
|
}), 1e3);
|
|
@@ -810,7 +814,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
810
814
|
const bots = ctx.bots.filter((v) => v.status === Universal3.Status.ONLINE && v.updateCommands);
|
|
811
815
|
bots.forEach((bot) => this.updateCommands(bot));
|
|
812
816
|
});
|
|
813
|
-
@@ -1334,6 +
|
|
817
|
+
@@ -1334,6 +1480,8 @@ var Commander = class {
|
|
814
818
|
static {
|
|
815
819
|
__name(this, "Commander");
|
|
816
820
|
}
|
|
@@ -819,7 +823,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
819
823
|
_commandList = [];
|
|
820
824
|
defineElementDomain(name, key = name, type = name) {
|
|
821
825
|
this.domain(name, (source, session) => {
|
|
822
|
-
@@ -1456,13 +
|
|
826
|
+
@@ -1456,13 +1604,14 @@ var Commander = class {
|
|
823
827
|
});
|
|
824
828
|
Object.assign(parent.config, config);
|
|
825
829
|
created.forEach((command) => this.ctx.emit("command-added", command));
|
|
@@ -837,7 +841,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
837
841
|
return this.ctx.set(service, { transform, ...options });
|
|
838
842
|
}
|
|
839
843
|
resolveDomain(type) {
|
|
840
|
-
@@ -1533,10 +
|
|
844
|
+
@@ -1533,10 +1682,10 @@ import { fallback, LocaleTree } from "@koishijs/i18n-utils";
|
|
841
845
|
import { h as h4, Logger as Logger2, Schema as Schema3 } from "@satorijs/core";
|
|
842
846
|
|
|
843
847
|
// src/locales/zh-CN.yml
|
|
@@ -850,7 +854,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
850
854
|
|
|
851
855
|
// src/i18n.ts
|
|
852
856
|
var logger2 = new Logger2("i18n");
|
|
853
|
-
@@ -1570,6 +
|
|
857
|
+
@@ -1570,6 +1719,8 @@ var I18n = class {
|
|
854
858
|
static {
|
|
855
859
|
__name(this, "I18n");
|
|
856
860
|
}
|
|
@@ -859,7 +863,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
859
863
|
_data = {};
|
|
860
864
|
_presets = {};
|
|
861
865
|
locales;
|
|
862
|
-
@@ -1613,7 +
|
|
866
|
+
@@ -1613,7 +1764,7 @@ var I18n = class {
|
|
863
867
|
const dict = this._data[locale] ||= {};
|
|
864
868
|
const paths = [...typeof args[0] === "string" ? this.set(locale, args[0] + ".", args[1]) : this.set(locale, "", args[0])];
|
|
865
869
|
this.ctx.emit("internal/i18n");
|
|
@@ -868,7 +872,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
868
872
|
for (const path2 of paths) {
|
|
869
873
|
delete dict[path2];
|
|
870
874
|
}
|
|
871
|
-
@@ -1680,7 +
|
|
875
|
+
@@ -1680,7 +1831,7 @@ var I18n = class {
|
|
872
876
|
import { observe } from "@koishijs/utils";
|
|
873
877
|
import { isNullable as isNullable4, makeArray as makeArray2 } from "cosmokit";
|
|
874
878
|
import { h as h5, Logger as Logger3 } from "@satorijs/core";
|
|
@@ -877,7 +881,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
877
881
|
var logger3 = new Logger3("session");
|
|
878
882
|
function collectFields(argv, collectors, fields) {
|
|
879
883
|
for (const collector of collectors) {
|
|
880
|
-
@@ -1700,7 +
|
|
884
|
+
@@ -1700,7 +1851,8 @@ var KoishiSession = class {
|
|
881
885
|
__name(this, "KoishiSession");
|
|
882
886
|
}
|
|
883
887
|
constructor(ctx) {
|
|
@@ -887,16 +891,16 @@ index b99cd02..ddbf1bf 100644
|
|
|
887
891
|
resolve: "session.resolve",
|
|
888
892
|
stripped: "session.stripped",
|
|
889
893
|
username: "session.username",
|
|
890
|
-
@@ -1969,7 +
|
|
894
|
+
@@ -1969,7 +2121,7 @@ var KoishiSession = class {
|
|
891
895
|
}
|
|
892
896
|
}
|
|
893
897
|
const { command } = argv;
|
|
894
898
|
- if (!command.ctx.filter(this)) return [];
|
|
895
|
-
+ if (!(command.ctx[
|
|
899
|
+
+ if (!(command.ctx[kFilter]?.(this) ?? true)) return [];
|
|
896
900
|
if (this.app.database) {
|
|
897
901
|
if (!this.isDirect) {
|
|
898
902
|
await this.observeChannel(this.collect("channel", argv, /* @__PURE__ */ new Set(["permissions", "locales"])));
|
|
899
|
-
@@ -2058,8 +
|
|
903
|
+
@@ -2058,8 +2210,7 @@ var logger4 = new Logger4("app");
|
|
900
904
|
var Permissions = class {
|
|
901
905
|
constructor(ctx) {
|
|
902
906
|
this.ctx = ctx;
|
|
@@ -906,7 +910,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
906
910
|
this.define("authority:(value)", {
|
|
907
911
|
check: /* @__PURE__ */ __name(({ value }, { user }) => {
|
|
908
912
|
return !user || user.authority >= +value;
|
|
909
|
-
@@ -2076,6 +
|
|
913
|
+
@@ -2076,6 +2227,8 @@ var Permissions = class {
|
|
910
914
|
static {
|
|
911
915
|
__name(this, "Permissions");
|
|
912
916
|
}
|
|
@@ -915,7 +919,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
915
919
|
store = [];
|
|
916
920
|
define(pattern, options) {
|
|
917
921
|
const entry = {
|
|
918
|
-
@@ -2167,7 +
|
|
922
|
+
@@ -2167,7 +2320,8 @@ var KoishiBot = class {
|
|
919
923
|
__name(this, "KoishiBot");
|
|
920
924
|
}
|
|
921
925
|
constructor(ctx) {
|
|
@@ -925,7 +929,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
925
929
|
getGuildMemberMap: "bot.getGuildMemberMap",
|
|
926
930
|
broadcast: "bot.broadcast"
|
|
927
931
|
});
|
|
928
|
-
@@ -2238,9 +
|
|
932
|
+
@@ -2238,9 +2392,11 @@ var SchemaService = class {
|
|
929
933
|
static {
|
|
930
934
|
__name(this, "SchemaService");
|
|
931
935
|
}
|
|
@@ -938,7 +942,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
938
942
|
const target = this.get(name);
|
|
939
943
|
const index = target.list.findIndex((a) => a[kSchemaOrder] < order);
|
|
940
944
|
schema[kSchemaOrder] = order;
|
|
941
|
-
@@ -2250,7 +
|
|
945
|
+
@@ -2250,7 +2406,7 @@ var SchemaService = class {
|
|
942
946
|
target.list.push(schema);
|
|
943
947
|
}
|
|
944
948
|
this.ctx.emit("internal/schema", name);
|
|
@@ -947,7 +951,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
947
951
|
remove3(target.list, schema);
|
|
948
952
|
this.ctx.emit("internal/schema", name);
|
|
949
953
|
});
|
|
950
|
-
@@ -2259,10 +
|
|
954
|
+
@@ -2259,10 +2415,10 @@ var SchemaService = class {
|
|
951
955
|
return this._data[name] ||= Schema4.intersect([]);
|
|
952
956
|
}
|
|
953
957
|
set(name, schema) {
|
|
@@ -960,7 +964,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
960
964
|
delete this._data[name];
|
|
961
965
|
this.ctx.emit("internal/schema", name);
|
|
962
966
|
});
|
|
963
|
-
@@ -2272,6 +
|
|
967
|
+
@@ -2272,6 +2428,95 @@ var SchemaService = class {
|
|
964
968
|
// src/context.ts
|
|
965
969
|
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";
|
|
966
970
|
import { resolveConfig } from "cordis";
|
|
@@ -982,7 +986,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
982
986
|
+ ctx.accessor("filter", {
|
|
983
987
|
+ get() {
|
|
984
988
|
+ const self = this;
|
|
985
|
-
+ return (session) => self[
|
|
989
|
+
+ return (session) => self[kFilter]?.(session) ?? true;
|
|
986
990
|
+ }
|
|
987
991
|
+ });
|
|
988
992
|
+ ctx.accessor("app", {
|
|
@@ -1056,7 +1060,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
1056
1060
|
var Context = class extends satori.Context {
|
|
1057
1061
|
static {
|
|
1058
1062
|
__name(this, "Context");
|
|
1059
|
-
@@ -2279,31 +
|
|
1063
|
+
@@ -2279,31 +2524,8 @@ var Context = class extends satori.Context {
|
|
1060
1064
|
static shadow = /* @__PURE__ */ Symbol.for("session.shadow");
|
|
1061
1065
|
constructor(config = {}) {
|
|
1062
1066
|
super(config);
|
|
@@ -1090,7 +1094,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
1090
1094
|
}
|
|
1091
1095
|
/** @deprecated use `ctx.root` instead */
|
|
1092
1096
|
get app() {
|
|
1093
|
-
@@ -2313,25 +
|
|
1097
|
+
@@ -2313,25 +2535,6 @@ var Context = class extends satori.Context {
|
|
1094
1098
|
get options() {
|
|
1095
1099
|
return this.root.config;
|
|
1096
1100
|
}
|
|
@@ -1116,7 +1120,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
1116
1120
|
before(name, listener, append = false) {
|
|
1117
1121
|
const seg = name.split("/");
|
|
1118
1122
|
seg[seg.length - 1] = "before-" + seg[seg.length - 1];
|
|
1119
|
-
@@ -2339,19 +
|
|
1123
|
+
@@ -2339,19 +2542,36 @@ var Context = class extends satori.Context {
|
|
1120
1124
|
}
|
|
1121
1125
|
};
|
|
1122
1126
|
var Koishi = class extends cordis.Service {
|
|
@@ -1156,11 +1160,11 @@ index b99cd02..ddbf1bf 100644
|
|
|
1156
1160
|
-satori.Session.prototype[Context.filter] = function(ctx) {
|
|
1157
1161
|
- return ctx.filter(this);
|
|
1158
1162
|
+satori.Session.prototype[cordis.Context.filter] = function(ctx) {
|
|
1159
|
-
+ return ctx[
|
|
1163
|
+
+ return ctx[kFilter]?.(this) ?? true;
|
|
1160
1164
|
};
|
|
1161
1165
|
((Context3) => {
|
|
1162
1166
|
Context3.Config = Schema5.intersect([
|
|
1163
|
-
@@ -2399,12 +
|
|
1167
|
+
@@ -2399,12 +2619,15 @@ var Service3 = class extends satori.Service {
|
|
1164
1168
|
this.ctx = new Context();
|
|
1165
1169
|
}
|
|
1166
1170
|
};
|
|
@@ -1176,7 +1180,7 @@ index b99cd02..ddbf1bf 100644
|
|
|
1176
1180
|
Context as App,
|
|
1177
1181
|
Argv,
|
|
1178
1182
|
Bot3 as Bot,
|
|
1179
|
-
@@ -2426,6 +
|
|
1183
|
+
@@ -2426,6 +2649,7 @@ export {
|
|
1180
1184
|
Schema6 as Schema,
|
|
1181
1185
|
SchemaService,
|
|
1182
1186
|
Service3 as Service,
|
|
File without changes
|