wx2tg-puppet 2.1.5 → 2.1.7
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 +12 -2
- package/dist/core/Message.js +1 -1
- package/dist/utils/audioUtil.d.ts +7 -0
- package/dist/utils/audioUtil.js +13 -0
- package/package.json +1 -1
package/dist/action/common.js
CHANGED
|
@@ -21,6 +21,7 @@ const EMOJI_1 = require("../core/EMOJI");
|
|
|
21
21
|
const VOICE_1 = require("../core/VOICE");
|
|
22
22
|
const ToolsApi_1 = require("../api/ToolsApi");
|
|
23
23
|
const Message_1 = require("../core/Message");
|
|
24
|
+
const audioUtil_1 = require("../utils/audioUtil");
|
|
24
25
|
// 检查是否是 Contact 类组成的数组
|
|
25
26
|
function isArrayOfContact(arr) {
|
|
26
27
|
// 先判断是否是数组
|
|
@@ -185,9 +186,18 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
|
|
|
185
186
|
if (res.data.Code !== 0) {
|
|
186
187
|
throw new Error(`发送视频失败: ${res.data.Message}`);
|
|
187
188
|
}
|
|
188
|
-
return new Message_1.ResponseMsg(res.data.Data
|
|
189
|
+
return new Message_1.ResponseMsg(res.data.Data);
|
|
189
190
|
}
|
|
190
191
|
else if (content instanceof VOICE_1.Voice) {
|
|
192
|
+
if (content.type === 2) {
|
|
193
|
+
const fileName = new Date().getDate();
|
|
194
|
+
const fb = file_box_1.FileBox.fromBase64(content.voiceBase64);
|
|
195
|
+
yield fb.toFile(fileName + '.mp3');
|
|
196
|
+
yield new audioUtil_1.SilkToMp3Converter().convertToSilk(fileName + '.mp3', fileName + '.silk');
|
|
197
|
+
const fbResult = file_box_1.FileBox.fromFile(fileName + '.silk');
|
|
198
|
+
content.voiceBase64 = yield fbResult.toBase64();
|
|
199
|
+
content.type = 4;
|
|
200
|
+
}
|
|
191
201
|
const res = yield MsgApi_1.msgApi.SendVoice({
|
|
192
202
|
"Base64": content.voiceBase64,
|
|
193
203
|
"ToWxid": toWxid,
|
|
@@ -198,7 +208,7 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
|
|
|
198
208
|
if (res.data.Code !== 0) {
|
|
199
209
|
throw new Error(`发送语音失败: ${res.data.Message}`);
|
|
200
210
|
}
|
|
201
|
-
return new Message_1.ResponseMsg(res.data.Data
|
|
211
|
+
return new Message_1.ResponseMsg(res.data.Data);
|
|
202
212
|
}
|
|
203
213
|
// }else if(content instanceof MiniApp){
|
|
204
214
|
// return SendMiniApp({
|
package/dist/core/Message.js
CHANGED
|
@@ -614,7 +614,7 @@ class ResponseMsg {
|
|
|
614
614
|
constructor(obj) {
|
|
615
615
|
var _a, _b;
|
|
616
616
|
this.newMsgId = (obj.NewMsgId || obj.newMsgId || obj.Newmsgid) + '';
|
|
617
|
-
this.msgId = (obj.ClientMsgid || obj.clientMsgId || obj.Msgid || obj.msgId) ? (obj.ClientMsgid || obj.clientMsgId || obj.Msgid || obj.msgId) + '' : '';
|
|
617
|
+
this.msgId = (obj.ClientMsgid || obj.clientMsgId || obj.ClientMsgId || obj.Msgid || obj.msgId) ? (obj.ClientMsgid || obj.clientMsgId || obj.ClientMsgId || obj.Msgid || obj.msgId) + '' : '';
|
|
618
618
|
this.createTime = obj.Createtime || obj.createTime || obj.CreateTime;
|
|
619
619
|
this.toWxid = ((_a = obj.ToUsetName) === null || _a === void 0 ? void 0 : _a.string) || ((_b = obj.ToUserName) === null || _b === void 0 ? void 0 : _b.string) || obj.toUserName;
|
|
620
620
|
}
|
|
@@ -6,4 +6,11 @@ export declare class SilkToMp3Converter {
|
|
|
6
6
|
* @returns A promise that resolves when the conversion is complete.
|
|
7
7
|
*/
|
|
8
8
|
convertToMp3(inputFilePath: string, outputFilePath: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a Silk file to MP3 format.
|
|
11
|
+
* @param inputFilePath - The path to the Silk file.
|
|
12
|
+
* @param outputFilePath - The desired path for the MP3 file.
|
|
13
|
+
* @returns A promise that resolves when the conversion is complete.
|
|
14
|
+
*/
|
|
15
|
+
convertToSilk(inputFilePath: string, outputFilePath: string): Promise<void>;
|
|
9
16
|
}
|
package/dist/utils/audioUtil.js
CHANGED
|
@@ -15,5 +15,18 @@ class SilkToMp3Converter {
|
|
|
15
15
|
voice.decode(inputFilePath, outputFilePath, { format: "mp3" }, (file) => resolve());
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts a Silk file to MP3 format.
|
|
20
|
+
* @param inputFilePath - The path to the Silk file.
|
|
21
|
+
* @param outputFilePath - The desired path for the MP3 file.
|
|
22
|
+
* @returns A promise that resolves when the conversion is complete.
|
|
23
|
+
*/
|
|
24
|
+
convertToSilk(inputFilePath, outputFilePath) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const WxVoice = require('wx-voice');
|
|
27
|
+
const voice = new WxVoice();
|
|
28
|
+
voice.encode(inputFilePath, outputFilePath, { format: "silk" }, (file) => resolve());
|
|
29
|
+
});
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
32
|
exports.SilkToMp3Converter = SilkToMp3Converter;
|