wx2tg-puppet 2.1.7 → 2.1.9
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/action/common.js +8 -2
- package/dist/core/Message.js +4 -1
- package/package.json +1 -1
package/dist/action/common.js
CHANGED
|
@@ -9,6 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
16
|
exports.revoke = exports.quote = exports.say = void 0;
|
|
14
17
|
const file_box_1 = require("file-box");
|
|
@@ -22,6 +25,7 @@ const VOICE_1 = require("../core/VOICE");
|
|
|
22
25
|
const ToolsApi_1 = require("../api/ToolsApi");
|
|
23
26
|
const Message_1 = require("../core/Message");
|
|
24
27
|
const audioUtil_1 = require("../utils/audioUtil");
|
|
28
|
+
const fs_1 = __importDefault(require("fs"));
|
|
25
29
|
// 检查是否是 Contact 类组成的数组
|
|
26
30
|
function isArrayOfContact(arr) {
|
|
27
31
|
// 先判断是否是数组
|
|
@@ -190,13 +194,15 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
|
|
|
190
194
|
}
|
|
191
195
|
else if (content instanceof VOICE_1.Voice) {
|
|
192
196
|
if (content.type === 2) {
|
|
193
|
-
const fileName = new Date().
|
|
197
|
+
const fileName = new Date().getTime();
|
|
194
198
|
const fb = file_box_1.FileBox.fromBase64(content.voiceBase64);
|
|
195
|
-
yield fb.toFile(fileName + '.mp3');
|
|
199
|
+
yield fb.toFile(fileName + '.mp3', true);
|
|
196
200
|
yield new audioUtil_1.SilkToMp3Converter().convertToSilk(fileName + '.mp3', fileName + '.silk');
|
|
197
201
|
const fbResult = file_box_1.FileBox.fromFile(fileName + '.silk');
|
|
198
202
|
content.voiceBase64 = yield fbResult.toBase64();
|
|
199
203
|
content.type = 4;
|
|
204
|
+
fs_1.default.unlinkSync(fileName + '.mp3');
|
|
205
|
+
fs_1.default.unlinkSync(fileName + '.silk');
|
|
200
206
|
}
|
|
201
207
|
const res = yield MsgApi_1.msgApi.SendVoice({
|
|
202
208
|
"Base64": content.voiceBase64,
|
package/dist/core/Message.js
CHANGED
|
@@ -538,7 +538,10 @@ class Message {
|
|
|
538
538
|
const converter = new audioUtil_1.SilkToMp3Converter();
|
|
539
539
|
yield converter.convertToMp3(silkFilePath, mp3FilePath);
|
|
540
540
|
fs.unlinkSync(silkFilePath);
|
|
541
|
-
|
|
541
|
+
const buffer = fs.readFileSync(mp3FilePath);
|
|
542
|
+
const fileBox = file_box_1.FileBox.fromBuffer(buffer, `${this.msg.MsgId}.mp3`);
|
|
543
|
+
fs.unlinkSync(mp3FilePath);
|
|
544
|
+
return fileBox;
|
|
542
545
|
}
|
|
543
546
|
else if (this.type() === MessageType_1.MessageType.Emoji) {
|
|
544
547
|
const xml = this.msg.Content;
|