@chatluna/patchbay 0.1.2 → 0.1.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatluna/patchbay",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Cordis 4 patches for Koishi, Satori, Satori adapters and Cordis plugins, wired into yarn, pnpm or npm",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/patchbay.json CHANGED
@@ -17,7 +17,11 @@
17
17
  {
18
18
  "name": "@cordisjs/plugin-http",
19
19
  "version": "1.5.2",
20
- "description": "Use resolveIntercept, which Cordis 4 renamed from resolveConfig"
20
+ "description": "Use resolveIntercept, which Cordis 4 renamed from resolveConfig; merge request headers per name and send the global FormData as multipart",
21
+ "fixes": [
22
+ "ChatLunaLab/v2-mirror#140",
23
+ "ChatLunaLab/v2-mirror#145"
24
+ ]
21
25
  },
22
26
  {
23
27
  "name": "@cordisjs/plugin-loader",
@@ -40,7 +44,8 @@
40
44
  "description": "Run Koishi on Cordis 4; also installed as koishi. Inject shapes are normalized by the @satorijs/core patch",
41
45
  "fixes": [
42
46
  "ChatLunaLab/boilerplate#12",
43
- "ChatLunaLab/v2-mirror#28"
47
+ "ChatLunaLab/v2-mirror#28",
48
+ "ChatLunaLab/v2-mirror#111"
44
49
  ],
45
50
  "dependencies": {
46
51
  "cordis": "^4.0.0-rc.8"
@@ -63,7 +68,10 @@
63
68
  {
64
69
  "name": "koishi-plugin-adapter-onebot",
65
70
  "version": "6.9.5",
66
- "description": "Import Satori directly and inject http, satori and timer"
71
+ "description": "Import Satori directly and inject http, satori and timer; mark friend_recall as a direct channel like private messages",
72
+ "fixes": [
73
+ "ChatLunaLab/v2-mirror#159"
74
+ ]
67
75
  }
68
76
  ],
69
77
  "aliases": {
@@ -1,13 +1,28 @@
1
1
  diff --git a/lib/index.js b/lib/index.js
2
- index 3acbdff..56c9913 100644
2
+ index 3acbdff..0fec2d3 100644
3
3
  --- a/lib/index.js
4
4
  +++ b/lib/index.js
5
- @@ -202,7 +202,7 @@ var Http = class _Http extends Service {
5
+ @@ -202,7 +202,9 @@ var Http = class _Http extends Service {
6
6
  });
7
7
  }
8
8
  resolveConfig(init) {
9
9
  - return this[Service.resolveConfig](this.config, init);
10
- + return { ...this[Service.resolveIntercept](), ...this.config, ...init };
10
+ + // Merge headers per name, so a request's own `headers` (undefined or a Headers instance too) layers over the client's.
11
+ + const configs = [this[Service.resolveIntercept](), this.config, init];
12
+ + return Object.assign({}, ...configs, { headers: Object.fromEntries(configs.flatMap((config) => [...new Headers(config?.headers)])) });
11
13
  }
12
14
  resolveURL(url, config, isWebSocket = false) {
13
15
  try {
16
+ @@ -281,7 +283,11 @@ var Http = class _Http extends Service {
17
+ }
18
+ const response = await this.ctx.waterfall(this, "http/fetch", url, init, config, () => {
19
+ this.ctx.logger("http:request").debug("%C %s", method, url.href);
20
+ - return this.undici.fetch(url, init);
21
+ + // The undici package serializes only its own FormData and would send the global one as "[object FormData]".
22
+ + if (!(init.body instanceof FormData) || init.body instanceof this.undici.FormData) return this.undici.fetch(url, init);
23
+ + const form = new this.undici.FormData();
24
+ + for (const [name, value] of init.body) form.append(name, value);
25
+ + return this.undici.fetch(url, { ...init, body: form });
26
+ }).catch((cause) => {
27
+ this.ctx.logger("http:request").debug("%C %s failed: %o", method, url.href, cause);
28
+ if (_Http.Error.is(cause)) throw cause;
@@ -292,7 +292,7 @@ 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..cbac35c 100644
295
+ index b99cd02..ddbf1bf 100644
296
296
  --- a/lib/index.mjs
297
297
  +++ b/lib/index.mjs
298
298
  @@ -2,16 +2,120 @@ var __defProp = Object.defineProperty;
@@ -691,27 +691,51 @@ index b99cd02..cbac35c 100644
691
691
  return this;
692
692
  }
693
693
  /** @deprecated */
694
- @@ -1095,7 +1231,9 @@ __name(toStringType, "toStringType");
694
+ @@ -1095,6 +1231,43 @@ __name(toStringType, "toStringType");
695
695
  // src/command/validate.ts
696
696
  import { isNullable as isNullable2 } from "cosmokit";
697
697
  function validate(ctx) {
698
- - ctx.permissions.define("command:(name)", {
699
- + const permissions = ctx.get("permissions", false);
700
- + if (!permissions) return;
701
- + permissions.define("command:(name)", {
698
+ + // patchbay: the gate comes and goes with the permission service, whichever loads first and across its reloads.
699
+ + ctx.inject(["permissions"], (ctx2) => validatePermissions(ctx2));
700
+ + ctx.before("command/execute", async (argv) => {
701
+ + const { args, options, command, session } = argv;
702
+ + function sendHint(message, ...param) {
703
+ + return command.config.showWarning ? session.text(message, param) : "";
704
+ + }
705
+ + __name(sendHint, "sendHint");
706
+ + if (command.config.checkArgCount) {
707
+ + let index = args.length;
708
+ + while (command._arguments[index]?.required) {
709
+ + const decl = command._arguments[index];
710
+ + await session.send(session.text("internal.prompt-argument", [
711
+ + session.text(`commands.${command.name}.arguments.${decl.name}`)
712
+ + ]));
713
+ + const source = await session.prompt();
714
+ + if (isNullable2(source)) {
715
+ + return sendHint("internal.insufficient-arguments", decl.name);
716
+ + }
717
+ + args.push(ctx.$commander.parseValue(source, "argument", argv, decl));
718
+ + index++;
719
+ + }
720
+ + const finalArg = command._arguments[command._arguments.length - 1] || {};
721
+ + if (args.length > command._arguments.length && !finalArg.variadic) {
722
+ + return sendHint("internal.redunant-arguments");
723
+ + }
724
+ + }
725
+ + if (command.config.checkUnknown) {
726
+ + const unknown = Object.keys(options).filter((key) => !command._options[key]);
727
+ + if (unknown.length) {
728
+ + return sendHint("internal.unknown-option", unknown.join(", "));
729
+ + }
730
+ + }
731
+ + }, true);
732
+ +}
733
+ +__name(validate, "validate");
734
+ +function validatePermissions(ctx) {
735
+ ctx.permissions.define("command:(name)", {
702
736
  depends: /* @__PURE__ */ __name(({ name }) => {
703
737
  const command = ctx.$commander.get(name);
704
- if (!command) return;
705
- @@ -1110,7 +1248,7 @@ function validate(ctx) {
706
- return ctx.$commander._commandList.map((command) => `command:${command.name}`);
707
- }, "list")
708
- });
709
- - ctx.permissions.define("command:(name):option:(name2)", {
710
- + permissions.define("command:(name):option:(name2)", {
711
- depends: /* @__PURE__ */ __name(({ name, name2 }) => {
712
- return ctx.$commander.get(name)?._options[name2]?.dependencies;
713
- }, "depends"),
714
- @@ -1130,13 +1268,13 @@ function validate(ctx) {
738
+ @@ -1130,50 +1303,19 @@ function validate(ctx) {
715
739
  return command.config.showWarning ? session.text(message, param) : "";
716
740
  }
717
741
  __name(sendHint, "sendHint");
@@ -720,15 +744,55 @@ index b99cd02..cbac35c 100644
720
744
  for (const option of Object.values(command._options)) {
721
745
  if (option.name in options) {
722
746
  - permissions.push(`command:${command.name}:option:${option.name}`);
747
+ - }
748
+ - }
749
+ - if (!await ctx.permissions.test(permissions, session)) {
750
+ - return sendHint("internal.low-authority");
751
+ - }
752
+ - }, true);
753
+ - ctx.before("command/execute", async (argv) => {
754
+ - const { args, options, command, session } = argv;
755
+ - function sendHint(message, ...param) {
756
+ - return command.config.showWarning ? session.text(message, param) : "";
757
+ - }
758
+ - __name(sendHint, "sendHint");
759
+ - if (command.config.checkArgCount) {
760
+ - let index = args.length;
761
+ - while (command._arguments[index]?.required) {
762
+ - const decl = command._arguments[index];
763
+ - await session.send(session.text("internal.prompt-argument", [
764
+ - session.text(`commands.${command.name}.arguments.${decl.name}`)
765
+ - ]));
766
+ - const source = await session.prompt();
767
+ - if (isNullable2(source)) {
768
+ - return sendHint("internal.insufficient-arguments", decl.name);
769
+ - }
770
+ - args.push(ctx.$commander.parseValue(source, "argument", argv, decl));
771
+ - index++;
772
+ - }
773
+ - const finalArg = command._arguments[command._arguments.length - 1] || {};
774
+ - if (args.length > command._arguments.length && !finalArg.variadic) {
775
+ - return sendHint("internal.redunant-arguments");
723
776
  + required.push(`command:${command.name}:option:${option.name}`);
724
777
  }
725
778
  }
726
- - if (!await ctx.permissions.test(permissions, session)) {
727
- + if (!await permissions.test(required, session)) {
728
- return sendHint("internal.low-authority");
779
+ - if (command.config.checkUnknown) {
780
+ - const unknown = Object.keys(options).filter((key) => !command._options[key]);
781
+ - if (unknown.length) {
782
+ - return sendHint("internal.unknown-option", unknown.join(", "));
783
+ - }
784
+ + if (!await ctx.permissions.test(required, session)) {
785
+ + const level = command.config.permissions?.map((name) => /^authority:(\d+)$/.exec(name)?.[1]).find(Boolean);
786
+ + return level === void 0 ? sendHint("internal.low-authority") : sendHint("internal.low-authority-level", command.displayName, level);
729
787
  }
730
788
  }, true);
731
- @@ -1182,7 +1320,7 @@ var Commander = class {
789
+ }
790
+ -__name(validate, "validate");
791
+ +__name(validatePermissions, "validatePermissions");
792
+
793
+ // src/command/index.ts
794
+ var isArray = Array.isArray;
795
+ @@ -1182,7 +1324,7 @@ var Commander = class {
732
796
  constructor(ctx, config = {}) {
733
797
  this.ctx = ctx;
734
798
  this.config = config;
@@ -737,7 +801,7 @@ index b99cd02..cbac35c 100644
737
801
  ctx.plugin(validate);
738
802
  ctx.before("parse", (content, session) => {
739
803
  const { isDirect, stripped: { prefix, appel } } = session;
740
- @@ -1255,7 +1393,7 @@ var Commander = class {
804
+ @@ -1255,7 +1397,7 @@ var Commander = class {
741
805
  permissions: Schema2.array(String).role("perms").default(["authority:0"]).description("权限继承。"),
742
806
  dependencies: Schema2.array(String).role("perms").description("权限依赖。")
743
807
  }), 1e3);
@@ -746,7 +810,7 @@ index b99cd02..cbac35c 100644
746
810
  const bots = ctx.bots.filter((v) => v.status === Universal3.Status.ONLINE && v.updateCommands);
747
811
  bots.forEach((bot) => this.updateCommands(bot));
748
812
  });
749
- @@ -1334,6 +1472,8 @@ var Commander = class {
813
+ @@ -1334,6 +1476,8 @@ var Commander = class {
750
814
  static {
751
815
  __name(this, "Commander");
752
816
  }
@@ -755,7 +819,7 @@ index b99cd02..cbac35c 100644
755
819
  _commandList = [];
756
820
  defineElementDomain(name, key = name, type = name) {
757
821
  this.domain(name, (source, session) => {
758
- @@ -1456,13 +1596,14 @@ var Commander = class {
822
+ @@ -1456,13 +1600,14 @@ var Commander = class {
759
823
  });
760
824
  Object.assign(parent.config, config);
761
825
  created.forEach((command) => this.ctx.emit("command-added", command));
@@ -773,7 +837,20 @@ index b99cd02..cbac35c 100644
773
837
  return this.ctx.set(service, { transform, ...options });
774
838
  }
775
839
  resolveDomain(type) {
776
- @@ -1570,6 +1711,8 @@ var I18n = class {
840
+ @@ -1533,10 +1678,10 @@ import { fallback, LocaleTree } from "@koishijs/i18n-utils";
841
+ import { h as h4, Logger as Logger2, Schema as Schema3 } from "@satorijs/core";
842
+
843
+ // src/locales/zh-CN.yml
844
+ -var zh_CN_default = { general: { $: "通用设置", name: "中文", paren: "({0})", quote: "“{0}”", comma: ",", and: "和", or: "或", day: "天", hour: "小时", minute: "分钟", second: "秒" }, internal: { $: "核心文本", "error-encountered": "发生未知错误。", "low-authority": "权限不足。", "prompt-argument": "请发送{0}。", "insufficient-arguments": "缺少参数,输入帮助以查看用法。", "redunant-arguments": "存在多余参数,输入帮助以查看用法。", "invalid-argument": "参数 {0} 输入无效,{1}", "unknown-option": "存在未知选项 {0},输入帮助以查看用法。", "invalid-option": "选项 {0} 输入无效,{1}", "check-syntax": "输入帮助以查看用法。", "invalid-number": "请提供一个数字。", "invalid-integer": "请提供一个整数。", "invalid-posint": "请提供一个正整数。", "invalid-natural": "请提供一个非负整数。", "invalid-date": "请输入合法的时间。", "invalid-user": "请指定正确的用户。", "invalid-channel": "请指定正确的频道。", "invalid-image": "请上传图片。", "invalid-audio": "请上传音频。", "invalid-video": "请上传视频。", "invalid-file": "请上传文件。", "suggest-hint": "您要找的是不是{0}?", "suggest-command": "回复句号以使用推测的指令。" }, commands: { $: "指令系统" } };
845
+ +var zh_CN_default = { general: { $: "通用设置", name: "中文", paren: "({0})", quote: "“{0}”", comma: ",", and: "和", or: "或", day: "天", hour: "小时", minute: "分钟", second: "秒" }, internal: { $: "核心文本", "error-encountered": "发生未知错误。", "low-authority": "权限不足。", "low-authority-level": "权限不足:{0} 需要 {1} 级权限。", "prompt-argument": "请发送{0}。", "insufficient-arguments": "缺少参数,输入帮助以查看用法。", "redunant-arguments": "存在多余参数,输入帮助以查看用法。", "invalid-argument": "参数 {0} 输入无效,{1}", "unknown-option": "存在未知选项 {0},输入帮助以查看用法。", "invalid-option": "选项 {0} 输入无效,{1}", "check-syntax": "输入帮助以查看用法。", "invalid-number": "请提供一个数字。", "invalid-integer": "请提供一个整数。", "invalid-posint": "请提供一个正整数。", "invalid-natural": "请提供一个非负整数。", "invalid-date": "请输入合法的时间。", "invalid-user": "请指定正确的用户。", "invalid-channel": "请指定正确的频道。", "invalid-image": "请上传图片。", "invalid-audio": "请上传音频。", "invalid-video": "请上传视频。", "invalid-file": "请上传文件。", "suggest-hint": "您要找的是不是{0}?", "suggest-command": "回复句号以使用推测的指令。" }, commands: { $: "指令系统" } };
846
+
847
+ // src/locales/en-US.yml
848
+ -var en_US_default = { general: { $: "General Settings", name: "English", paren: " ({0}) ", quote: '"{0}"', comma: ",", and: "and", or: "or", day: "day", hour: "hour", minute: "minute", second: "second" }, internal: { $: "Internal Text", "error-encountered": "An unknown error has occurred.", "low-authority": "Low authority.", "prompt-argument": "请发送{0}。", "insufficient-arguments": "Insufficient arguments, type help to see usage.", "redunant-arguments": "Redunant arguments, type help to see usage.", "invalid-argument": "Invalid argument {0}, {1}", "unknown-option": "Unknown option {0}, type help to see usage.", "invalid-option": "Invalid option {0}, {1}", "check-syntax": "Type help to see usage.", "invalid-number": "Expect a number.", "invalid-integer": "Expect an integer.", "invalid-posint": "Expect a positive integer.", "invalid-natural": "Expect a non-negative integer.", "invalid-date": "Expect a valid date.", "invalid-user": "Expect a valid user.", "invalid-channel": "Expect a valid channel.", "invalid-image": "Expect an image.", "invalid-audio": "Expect an audio.", "invalid-video": "Expect a video.", "invalid-file": "Expect a file.", "suggest-hint": "Do you mean {0}?", "suggest-command": "Send a period to apply the suggestion." }, commands: { $: "Command System" } };
849
+ +var en_US_default = { general: { $: "General Settings", name: "English", paren: " ({0}) ", quote: '"{0}"', comma: ",", and: "and", or: "or", day: "day", hour: "hour", minute: "minute", second: "second" }, internal: { $: "Internal Text", "error-encountered": "An unknown error has occurred.", "low-authority": "Low authority.", "low-authority-level": "Low authority: {0} needs level {1}.", "prompt-argument": "请发送{0}。", "insufficient-arguments": "Insufficient arguments, type help to see usage.", "redunant-arguments": "Redunant arguments, type help to see usage.", "invalid-argument": "Invalid argument {0}, {1}", "unknown-option": "Unknown option {0}, type help to see usage.", "invalid-option": "Invalid option {0}, {1}", "check-syntax": "Type help to see usage.", "invalid-number": "Expect a number.", "invalid-integer": "Expect an integer.", "invalid-posint": "Expect a positive integer.", "invalid-natural": "Expect a non-negative integer.", "invalid-date": "Expect a valid date.", "invalid-user": "Expect a valid user.", "invalid-channel": "Expect a valid channel.", "invalid-image": "Expect an image.", "invalid-audio": "Expect an audio.", "invalid-video": "Expect a video.", "invalid-file": "Expect a file.", "suggest-hint": "Do you mean {0}?", "suggest-command": "Send a period to apply the suggestion." }, commands: { $: "Command System" } };
850
+
851
+ // src/i18n.ts
852
+ var logger2 = new Logger2("i18n");
853
+ @@ -1570,6 +1715,8 @@ var I18n = class {
777
854
  static {
778
855
  __name(this, "I18n");
779
856
  }
@@ -782,7 +859,7 @@ index b99cd02..cbac35c 100644
782
859
  _data = {};
783
860
  _presets = {};
784
861
  locales;
785
- @@ -1613,7 +1756,7 @@ var I18n = class {
862
+ @@ -1613,7 +1760,7 @@ var I18n = class {
786
863
  const dict = this._data[locale] ||= {};
787
864
  const paths = [...typeof args[0] === "string" ? this.set(locale, args[0] + ".", args[1]) : this.set(locale, "", args[0])];
788
865
  this.ctx.emit("internal/i18n");
@@ -791,7 +868,7 @@ index b99cd02..cbac35c 100644
791
868
  for (const path2 of paths) {
792
869
  delete dict[path2];
793
870
  }
794
- @@ -1680,7 +1823,7 @@ var I18n = class {
871
+ @@ -1680,7 +1827,7 @@ var I18n = class {
795
872
  import { observe } from "@koishijs/utils";
796
873
  import { isNullable as isNullable4, makeArray as makeArray2 } from "cosmokit";
797
874
  import { h as h5, Logger as Logger3 } from "@satorijs/core";
@@ -800,7 +877,7 @@ index b99cd02..cbac35c 100644
800
877
  var logger3 = new Logger3("session");
801
878
  function collectFields(argv, collectors, fields) {
802
879
  for (const collector of collectors) {
803
- @@ -1700,7 +1843,8 @@ var KoishiSession = class {
880
+ @@ -1700,7 +1847,8 @@ var KoishiSession = class {
804
881
  __name(this, "KoishiSession");
805
882
  }
806
883
  constructor(ctx) {
@@ -810,7 +887,7 @@ index b99cd02..cbac35c 100644
810
887
  resolve: "session.resolve",
811
888
  stripped: "session.stripped",
812
889
  username: "session.username",
813
- @@ -1969,7 +2113,7 @@ var KoishiSession = class {
890
+ @@ -1969,7 +2117,7 @@ var KoishiSession = class {
814
891
  }
815
892
  }
816
893
  const { command } = argv;
@@ -819,7 +896,7 @@ index b99cd02..cbac35c 100644
819
896
  if (this.app.database) {
820
897
  if (!this.isDirect) {
821
898
  await this.observeChannel(this.collect("channel", argv, /* @__PURE__ */ new Set(["permissions", "locales"])));
822
- @@ -2058,8 +2202,7 @@ var logger4 = new Logger4("app");
899
+ @@ -2058,8 +2206,7 @@ var logger4 = new Logger4("app");
823
900
  var Permissions = class {
824
901
  constructor(ctx) {
825
902
  this.ctx = ctx;
@@ -829,7 +906,7 @@ index b99cd02..cbac35c 100644
829
906
  this.define("authority:(value)", {
830
907
  check: /* @__PURE__ */ __name(({ value }, { user }) => {
831
908
  return !user || user.authority >= +value;
832
- @@ -2076,6 +2219,8 @@ var Permissions = class {
909
+ @@ -2076,6 +2223,8 @@ var Permissions = class {
833
910
  static {
834
911
  __name(this, "Permissions");
835
912
  }
@@ -838,7 +915,7 @@ index b99cd02..cbac35c 100644
838
915
  store = [];
839
916
  define(pattern, options) {
840
917
  const entry = {
841
- @@ -2167,7 +2312,8 @@ var KoishiBot = class {
918
+ @@ -2167,7 +2316,8 @@ var KoishiBot = class {
842
919
  __name(this, "KoishiBot");
843
920
  }
844
921
  constructor(ctx) {
@@ -848,7 +925,7 @@ index b99cd02..cbac35c 100644
848
925
  getGuildMemberMap: "bot.getGuildMemberMap",
849
926
  broadcast: "bot.broadcast"
850
927
  });
851
- @@ -2238,9 +2384,11 @@ var SchemaService = class {
928
+ @@ -2238,9 +2388,11 @@ var SchemaService = class {
852
929
  static {
853
930
  __name(this, "SchemaService");
854
931
  }
@@ -861,7 +938,7 @@ index b99cd02..cbac35c 100644
861
938
  const target = this.get(name);
862
939
  const index = target.list.findIndex((a) => a[kSchemaOrder] < order);
863
940
  schema[kSchemaOrder] = order;
864
- @@ -2250,7 +2398,7 @@ var SchemaService = class {
941
+ @@ -2250,7 +2402,7 @@ var SchemaService = class {
865
942
  target.list.push(schema);
866
943
  }
867
944
  this.ctx.emit("internal/schema", name);
@@ -870,7 +947,7 @@ index b99cd02..cbac35c 100644
870
947
  remove3(target.list, schema);
871
948
  this.ctx.emit("internal/schema", name);
872
949
  });
873
- @@ -2259,10 +2407,10 @@ var SchemaService = class {
950
+ @@ -2259,10 +2411,10 @@ var SchemaService = class {
874
951
  return this._data[name] ||= Schema4.intersect([]);
875
952
  }
876
953
  set(name, schema) {
@@ -883,7 +960,7 @@ index b99cd02..cbac35c 100644
883
960
  delete this._data[name];
884
961
  this.ctx.emit("internal/schema", name);
885
962
  });
886
- @@ -2272,6 +2420,95 @@ var SchemaService = class {
963
+ @@ -2272,6 +2424,95 @@ var SchemaService = class {
887
964
  // src/context.ts
888
965
  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";
889
966
  import { resolveConfig } from "cordis";
@@ -979,7 +1056,7 @@ index b99cd02..cbac35c 100644
979
1056
  var Context = class extends satori.Context {
980
1057
  static {
981
1058
  __name(this, "Context");
982
- @@ -2279,31 +2516,8 @@ var Context = class extends satori.Context {
1059
+ @@ -2279,31 +2520,8 @@ var Context = class extends satori.Context {
983
1060
  static shadow = /* @__PURE__ */ Symbol.for("session.shadow");
984
1061
  constructor(config = {}) {
985
1062
  super(config);
@@ -1013,7 +1090,7 @@ index b99cd02..cbac35c 100644
1013
1090
  }
1014
1091
  /** @deprecated use `ctx.root` instead */
1015
1092
  get app() {
1016
- @@ -2313,25 +2527,6 @@ var Context = class extends satori.Context {
1093
+ @@ -2313,25 +2531,6 @@ var Context = class extends satori.Context {
1017
1094
  get options() {
1018
1095
  return this.root.config;
1019
1096
  }
@@ -1039,7 +1116,7 @@ index b99cd02..cbac35c 100644
1039
1116
  before(name, listener, append = false) {
1040
1117
  const seg = name.split("/");
1041
1118
  seg[seg.length - 1] = "before-" + seg[seg.length - 1];
1042
- @@ -2339,19 +2534,36 @@ var Context = class extends satori.Context {
1119
+ @@ -2339,19 +2538,36 @@ var Context = class extends satori.Context {
1043
1120
  }
1044
1121
  };
1045
1122
  var Koishi = class extends cordis.Service {
@@ -1083,7 +1160,7 @@ index b99cd02..cbac35c 100644
1083
1160
  };
1084
1161
  ((Context3) => {
1085
1162
  Context3.Config = Schema5.intersect([
1086
- @@ -2399,12 +2611,15 @@ var Service3 = class extends satori.Service {
1163
+ @@ -2399,12 +2615,15 @@ var Service3 = class extends satori.Service {
1087
1164
  this.ctx = new Context();
1088
1165
  }
1089
1166
  };
@@ -1099,7 +1176,7 @@ index b99cd02..cbac35c 100644
1099
1176
  Context as App,
1100
1177
  Argv,
1101
1178
  Bot3 as Bot,
1102
- @@ -2426,6 +2641,7 @@ export {
1179
+ @@ -2426,6 +2645,7 @@ export {
1103
1180
  Schema6 as Schema,
1104
1181
  SchemaService,
1105
1182
  Service3 as Service,
@@ -78,7 +78,7 @@ index 120885c..d5ba237 100644
78
78
  'onebot/message-reactions-updated'(session: Session): void;
79
79
  'onebot/channel-updated'(session: Session): void;
80
80
  diff --git a/lib/index.js b/lib/index.js
81
- index 996a9c8..5b58e18 100644
81
+ index 996a9c8..cf1e9bd 100644
82
82
  --- a/lib/index.js
83
83
  +++ b/lib/index.js
84
84
  @@ -46,10 +46,10 @@ __export(index_exports, {
@@ -108,7 +108,15 @@ index 996a9c8..5b58e18 100644
108
108
  var SafetyLevel = /* @__PURE__ */ ((SafetyLevel2) => {
109
109
  SafetyLevel2[SafetyLevel2["safe"] = 0] = "safe";
110
110
  SafetyLevel2[SafetyLevel2["unknown"] = 1] = "unknown";
111
- @@ -594,7 +594,7 @@ var HttpServer = class extends import_koishi3.Adapter {
111
+ @@ -466,6 +466,7 @@ async function adaptSession(bot, data) {
112
+ session.type = "message-deleted";
113
+ session.subtype = "private";
114
+ session.channelId = `private:${session.userId}`;
115
+ + session.isDirect = true;
116
+ break;
117
+ // from go-cqhttp source code, but not mentioned in official docs
118
+ case "guild_channel_recall":
119
+ @@ -594,7 +595,7 @@ var HttpServer = class extends import_koishi3.Adapter {
112
120
  })(HttpServer || (HttpServer = {}));
113
121
 
114
122
  // src/ws.ts
@@ -117,7 +125,7 @@ index 996a9c8..5b58e18 100644
117
125
  var WsClient = class extends import_koishi4.Adapter.WsClient {
118
126
  static {
119
127
  __name(this, "WsClient");
120
- @@ -734,10 +734,10 @@ function accept(socket, bot) {
128
+ @@ -734,10 +735,10 @@ function accept(socket, bot) {
121
129
  __name(accept, "accept");
122
130
 
123
131
  // src/bot/base.ts
@@ -130,7 +138,7 @@ index 996a9c8..5b58e18 100644
130
138
  var import_node_url = require("node:url");
131
139
  var State = class {
132
140
  constructor(type) {
133
- @@ -830,7 +830,7 @@ var OneBotMessageEncoder = class extends import_koishi5.MessageEncoder {
141
+ @@ -830,7 +831,7 @@ var OneBotMessageEncoder = class extends import_koishi5.MessageEncoder {
134
142
  }
135
143
  async sendFile(attrs) {
136
144
  const src = attrs.src || attrs.url;
@@ -139,7 +147,7 @@ index 996a9c8..5b58e18 100644
139
147
  const file = src.startsWith("file:") ? (0, import_node_url.fileURLToPath)(src) : await this.bot.internal.downloadFile(src);
140
148
  if (this.session.event.channel.type === import_koishi5.Universal.Channel.Type.DIRECT) {
141
149
  await this.bot.internal.uploadPrivateFile(
142
- @@ -977,7 +977,7 @@ var BaseBot2 = class extends import_koishi6.Bot {
150
+ @@ -977,7 +978,7 @@ var BaseBot2 = class extends import_koishi6.Bot {
143
151
  __name(this, "BaseBot");
144
152
  }
145
153
  static MessageEncoder = OneBotMessageEncoder;
@@ -148,7 +156,7 @@ index 996a9c8..5b58e18 100644
148
156
  parent;
149
157
  internal;
150
158
  async createDirectChannel(userId) {
151
- @@ -1112,7 +1112,7 @@ var QQGuildBot = class extends BaseBot2 {
159
+ @@ -1112,7 +1113,7 @@ var QQGuildBot = class extends BaseBot2 {
152
160
  };
153
161
 
154
162
  // src/bot/cqcode.ts