koishi-plugin-adapter-onebot-multi 1.0.3 → 1.0.5

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
@@ -70,7 +70,7 @@ declare module 'koishi' {
70
70
  'onebot-multi/bot-offline'(bot: OneBotBot): void;
71
71
  }
72
72
  }
73
- declare module '@satorijs/core' {
73
+ declare module 'koishi' {
74
74
  interface Session {
75
75
  onebot?: OneBot.Payload & OneBot.Internal;
76
76
  }
package/lib/index.js CHANGED
@@ -146,7 +146,7 @@ var Internal = class _Internal {
146
146
  static prepareArg(name2, params, args) {
147
147
  const fixedArg = Object.fromEntries(params.map((name3, index) => [name3, args[index]]));
148
148
  for (const key in fixedArg) {
149
- if (!name2.includes("guild") && key.endsWith("_id")) {
149
+ if (!name2.includes("guild") && key.endsWith("_id") && key !== "message_id") {
150
150
  const value = +fixedArg[key];
151
151
  if (Math.abs(value) < 4294967296) {
152
152
  fixedArg[key] = value;
@@ -350,9 +350,15 @@ async function adaptMessage(bot, data, message = {}, payload = message) {
350
350
  const [guildId, channelId] = decodeGuildChannelId(data);
351
351
  if (message.elements[0]?.type === "reply") {
352
352
  const reply = message.elements.shift();
353
- message.quote = await bot.getMessage(channelId, reply.attrs.id).catch((error) => {
354
- bot.logger.warn(error);
355
- return void 0;
353
+ const replyId = String(reply.attrs.id);
354
+ message.quote = await bot.getMessage(channelId, replyId).catch((error) => {
355
+ bot.logger.warn(
356
+ "failed to fetch quoted message %s in %s: %s",
357
+ replyId,
358
+ channelId,
359
+ error?.message || error
360
+ );
361
+ return { id: replyId };
356
362
  });
357
363
  }
358
364
  message.content = message.elements.join("");
@@ -496,6 +502,7 @@ async function adaptSession(bot, data) {
496
502
  if (session.subtype === "poke") {
497
503
  session.channelId ||= `private:${session.userId}`;
498
504
  } else if (session.subtype === "honor") {
505
+ ;
499
506
  session.subsubtype = (0, import_koishi2.hyphenate)(data.honor_type);
500
507
  }
501
508
  break;
@@ -1723,8 +1730,13 @@ var LoadBalancer = class {
1723
1730
  }
1724
1731
  }
1725
1732
  if (assignments.length > 0) {
1726
- for (const { channelId, assignee } of assignments) {
1727
- this.lastAssignees.set(channelId, assignee);
1733
+ const batchSize = 100;
1734
+ for (let i = 0; i < assignments.length; i += batchSize) {
1735
+ const slice = assignments.slice(i, i + batchSize);
1736
+ await Promise.all(slice.map(async ({ channelId, assignee }) => {
1737
+ await this.ctx.database.setChannel("onebot", channelId, { assignee });
1738
+ this.lastAssignees.set(channelId, assignee);
1739
+ }));
1728
1740
  }
1729
1741
  }
1730
1742
  const botsWithData = onlineBots.filter((id) => {
@@ -2123,10 +2135,10 @@ var ConfigStore = class {
2123
2135
  };
2124
2136
 
2125
2137
  // src/index.ts
2126
- var Config = import_koishi9.Schema.object({}).description("配置已迁移到 data/adapter-onebot-multi/config.yaml");
2138
+ var Config = import_koishi9.Schema.object({}).description("在侧边栏webui使用,配置文件在data/adapter-onebot-multi/config.yaml");
2127
2139
  var name = "adapter-onebot-multi";
2128
2140
  var inject = {
2129
- required: ["server"],
2141
+ required: ["server", "database"],
2130
2142
  optional: ["console"]
2131
2143
  };
2132
2144
  function apply(ctx, _config) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-adapter-onebot-multi",
3
3
  "description": "奶龙bot定制版onebot适配器,支持自动负载均衡与黑白名单,控制台侧边栏管理",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -39,13 +39,14 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@koishijs/plugin-console": "^5.30.0",
42
- "koishi": "^4.18.6"
42
+ "koishi": "*"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@koishijs/client": "^5.30.0",
46
46
  "@koishijs/plugin-console": "^5.30.8",
47
47
  "@koishijs/plugin-server": "^3.2.4",
48
- "@types/node": "^22.7.5"
48
+ "@types/node": "^22.7.5",
49
+ "koishi": "^4.18.11"
49
50
  },
50
51
  "dependencies": {
51
52
  "qface": "^1.4.1",