wx2tg-puppet 2.1.8 → 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.
@@ -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
  // 先判断是否是数组
@@ -197,6 +201,8 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
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,
@@ -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
- return file_box_1.FileBox.fromFile(mp3FilePath);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wx2tg-puppet",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [