@chatluna/patchbay 0.1.9 → 0.1.11

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.9",
3
+ "version": "0.1.11",
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
@@ -74,26 +74,28 @@
74
74
  {
75
75
  "name": "@satorijs/adapter-qq",
76
76
  "version": "4.14.1",
77
- "description": "Decode official QQ group_openid targets, ARK cards, nested chat records and index-only quotes; keep absolute channel image URLs",
77
+ "description": "Decode official QQ group_openid targets, ARK cards, nested chat records and index-only quotes; keep absolute channel image URLs and literal markup in guild text",
78
78
  "fixes": [
79
79
  "ChatLunaLab/v2-mirror#84",
80
80
  "ChatLunaLab/v2-mirror#93",
81
81
  "ChatLunaLab/v2-mirror#134",
82
82
  "ChatLunaLab/v2-mirror#135",
83
83
  "ChatLunaLab/v2-mirror#136",
84
- "ChatLunaLab/v2-mirror#139"
84
+ "ChatLunaLab/v2-mirror#139",
85
+ "ChatLunaLab/v2-mirror#225"
85
86
  ]
86
87
  },
87
88
  {
88
89
  "name": "@satorijs/adapter-telegram",
89
90
  "version": "4.5.11",
90
- "description": "Mention the bot by username, decode contacts, polls, dice and venues, scope albums and forum topics to their chat, and omit missing ids from uploads",
91
+ "description": "Mention the bot by username, decode contacts, polls, dice, venues and video notes, scope albums and forum topics to their chat, and omit missing ids from uploads",
91
92
  "fixes": [
92
93
  "ChatLunaLab/v2-mirror#146",
93
94
  "ChatLunaLab/v2-mirror#148",
94
95
  "ChatLunaLab/v2-mirror#149",
95
96
  "ChatLunaLab/v2-mirror#151",
96
- "ChatLunaLab/v2-mirror#164"
97
+ "ChatLunaLab/v2-mirror#164",
98
+ "ChatLunaLab/v2-mirror#226"
97
99
  ]
98
100
  },
99
101
  {
@@ -1,5 +1,5 @@
1
1
  diff --git a/lib/index.cjs b/lib/index.cjs
2
- index 4e1bd28..a19e6b9 100644
2
+ index 4e1bd28..ce022b9 100644
3
3
  --- a/lib/index.cjs
4
4
  +++ b/lib/index.cjs
5
5
  @@ -293,6 +293,7 @@ var decodeGuildMember = /* @__PURE__ */ __name((member) => ({
@@ -96,8 +96,12 @@ index 4e1bd28..a19e6b9 100644
96
96
  payload.user = { id: data.author.id, avatar: `https://q.qlogo.cn/qqapp/${bot.config.id}/${data.author.id}/640` };
97
97
  if (data.author.username) payload.user.name = data.author.username;
98
98
  if (data.author.member_role) payload.member = { roles: [{ id: data.author.member_role }] };
99
- @@ -407,7 +427,7 @@ async function decodeMessage(bot, data, message = {}, payload = message) {
100
- message.content = (data.content ?? "").replace(/<@!(\d+)>/g, (_, $1) => import_core.h.at($1).toString());
99
+ @@ -404,10 +424,10 @@ function decodeGroupMessage(bot, data, message = {}, payload = message) {
100
+ __name(decodeGroupMessage, "decodeGroupMessage");
101
+ async function decodeMessage(bot, data, message = {}, payload = message) {
102
+ message.id = message.messageId = data.id;
103
+ - message.content = (data.content ?? "").replace(/<@!(\d+)>/g, (_, $1) => import_core.h.at($1).toString());
104
+ + message.content = (data.content ?? "").split(/<@!(\d+)>/).map((part, index) => index % 2 ? import_core.h.at(part).toString() : import_core.h.escape(part)).join("");
101
105
  const { attachments = [] } = data;
102
106
  if (attachments.length && !/\s$/.test(message.content)) message.content += " ";
103
107
  - message.content = attachments.filter(({ content_type }) => content_type.startsWith("image")).reduce((content, attachment) => content + import_core.h.image("https://" + attachment.url), message.content);
@@ -105,3 +109,14 @@ index 4e1bd28..a19e6b9 100644
105
109
  message.elements = import_core.h.parse(message.content);
106
110
  message.elements = import_core.h.transform(message.elements, {
107
111
  text: /* @__PURE__ */ __name((attrs) => import_core.h.unescape(attrs.content), "text")
112
+ @@ -2273,6 +2293,10 @@ var QQBot = class extends import_core7.Bot {
113
+ await this.internal.deletePrivateMessage(channelId, messageId);
114
+ }
115
+ }
116
+ + // Group and C2C openids carry no profile endpoint; the avatar is derived from appid + openid.
117
+ + async getUser(userId) {
118
+ + return { id: userId, avatar: `https://q.qlogo.cn/qqapp/${this.config.id}/${userId}/640` };
119
+ + }
120
+ async getGuild(guildId) {
121
+ const data = await this.internal.getGuildInfo(guildId);
122
+ return { id: data.group_openid, name: data.group_name };
@@ -1,5 +1,5 @@
1
1
  diff --git a/lib/index.cjs b/lib/index.cjs
2
- index 01364de..822374f 100644
2
+ index 01364de..27e76a5 100644
3
3
  --- a/lib/index.cjs
4
4
  +++ b/lib/index.cjs
5
5
  @@ -244,10 +244,11 @@ async function handleUpdate(update, bot) {
@@ -66,7 +66,16 @@ index 01364de..822374f 100644
66
66
  } else if (data.photo) {
67
67
  const photo = data.photo.sort((s1, s2) => s2.file_size - s1.file_size)[0];
68
68
  segments.push((0, import_core.h)("img", await bot.$getFileFromId(photo.file_id)));
69
- @@ -442,7 +451,7 @@ async function decodeMessage(bot, data, message, payload = message) {
69
+ @@ -419,6 +428,8 @@ async function decodeMessage(bot, data, message, payload = message) {
70
+ await addResource("img", data.animation);
71
+ } else if (data.video) {
72
+ await addResource("video", data.video);
73
+ + } else if (data.video_note) {
74
+ + await addResource("video", data.video_note);
75
+ } else if (data.document) {
76
+ await addResource("file", data.document);
77
+ } else if (data.audio) {
78
+ @@ -442,7 +453,7 @@ async function decodeMessage(bot, data, message, payload = message) {
70
79
  };
71
80
  payload.member = {};
72
81
  payload.channel = {
@@ -75,7 +84,7 @@ index 01364de..822374f 100644
75
84
  type: import_core.Universal.Channel.Type.TEXT
76
85
  };
77
86
  }
78
- @@ -461,9 +470,12 @@ var TelegramMessageEncoder = class extends import_core2.MessageEncoder {
87
+ @@ -461,9 +472,12 @@ var TelegramMessageEncoder = class extends import_core2.MessageEncoder {
79
88
  mode = "default";
80
89
  rows = [];
81
90
  async prepare() {
@@ -90,7 +99,7 @@ index 01364de..822374f 100644
90
99
  this.payload.message_thread_id = +this.channelId;
91
100
  }
92
101
  }
93
- @@ -564,8 +576,8 @@ var TelegramMessageEncoder = class extends import_core2.MessageEncoder {
102
+ @@ -564,8 +578,8 @@ var TelegramMessageEncoder = class extends import_core2.MessageEncoder {
94
103
  formData.append("chat_id", this.payload.chat_id);
95
104
  formData.append("caption", this.payload.caption);
96
105
  formData.append("parse_mode", this.payload.parse_mode);
@@ -101,7 +110,7 @@ index 01364de..822374f 100644
101
110
  formData.append("has_spoiler", files[0].element.attrs.spoiler ? "true" : "false");
102
111
  formData.append(dataKey, "attach://" + files[0].filename);
103
112
  formData.append(files[0].filename, new Blob([files[0].data], { type: files[0].mime }), files[0].filename);
104
- @@ -874,10 +886,12 @@ var TelegramBot = class _TelegramBot extends import_core5.Bot {
113
+ @@ -874,10 +888,12 @@ var TelegramBot = class _TelegramBot extends import_core5.Bot {
105
114
  this.online();
106
115
  }
107
116
  async deleteMessage(chat_id, message_id) {