wechaty-web-panel 1.6.117 → 1.6.119
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/dist/common/index.js +8 -4
- package/dist/package-json.js +1 -1
- package/package.json +1 -1
- package/src/common/index.js +8 -4
- package/src/package-json.js +1 -1
package/dist/common/index.js
CHANGED
|
@@ -9,7 +9,8 @@ import { getPuppetEol, isWindowsPlatform } from "../const/puppet-type.js";
|
|
|
9
9
|
import dayjs from "dayjs";
|
|
10
10
|
import { addHistory } from "../db/chatHistory.js";
|
|
11
11
|
import { getPuppetInfo } from "../db/puppetDb.js";
|
|
12
|
-
import
|
|
12
|
+
import url from 'url';
|
|
13
|
+
import path from 'path';
|
|
13
14
|
async function formatContent(text) {
|
|
14
15
|
text = text.replaceAll('\\n', '\n');
|
|
15
16
|
const isWin = await isWindowsPlatform();
|
|
@@ -229,6 +230,7 @@ function getFileNameFromUrl(fileUrl) {
|
|
|
229
230
|
return decodeURIComponent(path.basename(urlObj.pathname));
|
|
230
231
|
}
|
|
231
232
|
catch (err) {
|
|
233
|
+
console.error('获取文件名失败', err);
|
|
232
234
|
return null;
|
|
233
235
|
}
|
|
234
236
|
}
|
|
@@ -268,9 +270,10 @@ async function roomSay(room, contact, msg, noNeedAt = false) {
|
|
|
268
270
|
}
|
|
269
271
|
else if (msg.type === 2 && msg.url) {
|
|
270
272
|
// url文件
|
|
271
|
-
|
|
273
|
+
const name = getFileNameFromUrl(msg.url);
|
|
274
|
+
let obj = FileBox.fromUrl(encodeURI(msg.url), name);
|
|
272
275
|
if (obj.mediaType === 'image/webp') {
|
|
273
|
-
obj = FileBox.fromUrl(`${AIBOTK_OUTAPI}/convert?url=${msg.url}
|
|
276
|
+
obj = FileBox.fromUrl(`${AIBOTK_OUTAPI}/convert?url=${msg.url}`);
|
|
274
277
|
}
|
|
275
278
|
// contact ? await room.say('', contact) : ''
|
|
276
279
|
await delay(500);
|
|
@@ -361,7 +364,8 @@ async function contactSay(contact, msg, isRoom = false) {
|
|
|
361
364
|
}
|
|
362
365
|
else if (msg.type === 2 && msg.url) {
|
|
363
366
|
// url文件
|
|
364
|
-
|
|
367
|
+
const name = getFileNameFromUrl(msg.url);
|
|
368
|
+
let obj = FileBox.fromUrl(encodeURI(msg.url), name);
|
|
365
369
|
await obj.ready();
|
|
366
370
|
if (obj.mediaType === 'image/webp') {
|
|
367
371
|
obj = FileBox.fromUrl(`${AIBOTK_OUTAPI}/convert?url=${msg.url}`, getFileNameFromUrl(msg.url));
|
package/dist/package-json.js
CHANGED
package/package.json
CHANGED
package/src/common/index.js
CHANGED
|
@@ -9,7 +9,8 @@ import { getPuppetEol, isWindowsPlatform } from "../const/puppet-type.js";
|
|
|
9
9
|
import dayjs from "dayjs";
|
|
10
10
|
import { addHistory } from "../db/chatHistory.js";
|
|
11
11
|
import { getPuppetInfo } from "../db/puppetDb.js";
|
|
12
|
-
import
|
|
12
|
+
import url from 'url'
|
|
13
|
+
import path from 'path'
|
|
13
14
|
|
|
14
15
|
async function formatContent(text) {
|
|
15
16
|
text = text.replaceAll('\\n', '\n');
|
|
@@ -235,6 +236,7 @@ function getFileNameFromUrl(fileUrl) {
|
|
|
235
236
|
path.basename(urlObj.pathname)
|
|
236
237
|
);
|
|
237
238
|
} catch (err) {
|
|
239
|
+
console.error('获取文件名失败', err);
|
|
238
240
|
return null;
|
|
239
241
|
}
|
|
240
242
|
}
|
|
@@ -271,9 +273,10 @@ async function roomSay(room, contact, msg, noNeedAt = false) {
|
|
|
271
273
|
void addReplyHistory(this, { content, contact: null, room: room } )
|
|
272
274
|
} else if (msg.type === 2 && msg.url) {
|
|
273
275
|
// url文件
|
|
274
|
-
|
|
276
|
+
const name = getFileNameFromUrl(msg.url)
|
|
277
|
+
let obj = FileBox.fromUrl(encodeURI(msg.url), name)
|
|
275
278
|
if(obj.mediaType === 'image/webp') {
|
|
276
|
-
obj = FileBox.fromUrl(`${AIBOTK_OUTAPI}/convert?url=${msg.url}
|
|
279
|
+
obj = FileBox.fromUrl(`${AIBOTK_OUTAPI}/convert?url=${msg.url}`)
|
|
277
280
|
}
|
|
278
281
|
// contact ? await room.say('', contact) : ''
|
|
279
282
|
await delay(500)
|
|
@@ -357,7 +360,8 @@ async function contactSay(contact, msg, isRoom = false) {
|
|
|
357
360
|
void addReplyHistory(this, { content, contact, room: null } )
|
|
358
361
|
} else if (msg.type === 2 && msg.url) {
|
|
359
362
|
// url文件
|
|
360
|
-
|
|
363
|
+
const name = getFileNameFromUrl(msg.url)
|
|
364
|
+
let obj = FileBox.fromUrl(encodeURI(msg.url), name)
|
|
361
365
|
await obj.ready()
|
|
362
366
|
if(obj.mediaType === 'image/webp') {
|
|
363
367
|
obj = FileBox.fromUrl(`${AIBOTK_OUTAPI}/convert?url=${msg.url}`, getFileNameFromUrl(msg.url))
|