@mrlingxd/koishi-plugin-adapter-onebot 0.2.3 → 0.2.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/lib/bot/message.js +4 -16
- package/package.json +1 -1
package/lib/bot/message.js
CHANGED
|
@@ -164,28 +164,16 @@ export class OneBotMessageEncoder extends MessageEncoder {
|
|
|
164
164
|
this.text(`(${attrs.href})`);
|
|
165
165
|
}
|
|
166
166
|
else if (["video", "audio", "image", "img"].includes(type)) {
|
|
167
|
-
|
|
167
|
+
const typeMap = { video: "video", audio: "record", img: "image", image: "image" };
|
|
168
|
+
const childrenType = typeMap[type];
|
|
168
169
|
if (type === "video" || type === "audio") {
|
|
169
170
|
await this.flush();
|
|
170
171
|
}
|
|
171
|
-
if (type === "video")
|
|
172
|
-
childrenType = "video";
|
|
173
|
-
if (type === "audio")
|
|
174
|
-
childrenType = "record";
|
|
175
|
-
if (type === "img")
|
|
176
|
-
childrenType = "image";
|
|
177
172
|
attrs = { ...attrs };
|
|
178
|
-
attrs.file = attrs.src || attrs.url;
|
|
173
|
+
attrs.file = attrs.src || attrs.url || attrs.file;
|
|
179
174
|
delete attrs.src;
|
|
180
175
|
delete attrs.url;
|
|
181
|
-
|
|
182
|
-
attrs.cache = 1;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
attrs.cache = 0;
|
|
186
|
-
}
|
|
187
|
-
// https://github.com/koishijs/koishi-plugin-adapter-onebot/issues/30
|
|
188
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
176
|
+
attrs.cache = attrs.cache ? 1 : 0;
|
|
189
177
|
const cap = /^data:([\w/.+-]+);base64,/.exec(attrs.file);
|
|
190
178
|
if (cap)
|
|
191
179
|
attrs.file = "base64://" + attrs.file.slice(cap[0].length);
|