wx2tg-puppet 2.2.4 → 3.0.0
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 +10 -6
- package/dist/api/ToolsApi.d.ts +2 -0
- package/dist/api/ToolsApi.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -1
- package/package.json +1 -1
package/dist/action/common.js
CHANGED
|
@@ -136,13 +136,17 @@ const say = (content, toWxid, ats) => __awaiter(void 0, void 0, void 0, function
|
|
|
136
136
|
return new Message_1.ResponseMsg(imgRes.data.Data);
|
|
137
137
|
case 'other':
|
|
138
138
|
// 直接从 FileBox 获取文件内容
|
|
139
|
-
const fileBuffer =
|
|
140
|
-
const fileBlob = new Blob([fileBuffer], { type: 'application/octet-stream' });
|
|
139
|
+
// const fileBuffer = await content.toBuffer();
|
|
140
|
+
// const fileBlob = new Blob([fileBuffer], { type: 'application/octet-stream' });
|
|
141
141
|
// 创建 FormData
|
|
142
|
-
const formData = new FormData();
|
|
143
|
-
formData.append('wxid',
|
|
144
|
-
formData.append('file', fileBlob, fileName);
|
|
145
|
-
const
|
|
142
|
+
// const formData = new FormData();
|
|
143
|
+
// formData.append('wxid', config?.wxid || '');
|
|
144
|
+
// formData.append('file', fileBlob, fileName);
|
|
145
|
+
const fileBase64 = yield content.toBase64();
|
|
146
|
+
const res = yield ToolsApi_1.toolsApi.UploadAppAttachApi({
|
|
147
|
+
"Wxid": config === null || config === void 0 ? void 0 : config.wxid,
|
|
148
|
+
"fileData": fileBase64
|
|
149
|
+
});
|
|
146
150
|
if (res.data.Code !== 0) {
|
|
147
151
|
throw new Error(`上传文件失败: ${res.data.Message}`);
|
|
148
152
|
}
|
package/dist/api/ToolsApi.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ declare class ToolsApi {
|
|
|
33
33
|
UpdateStepNumberApi(body: any): Promise<AxiosResponse<ApiResponse>>;
|
|
34
34
|
/** 文件上传 */
|
|
35
35
|
UploadFile(body: any): Promise<AxiosResponse<ApiResponse>>;
|
|
36
|
+
/** 文件上传 */
|
|
37
|
+
UploadAppAttachApi(body: any): Promise<AxiosResponse<ApiResponse>>;
|
|
36
38
|
/** 二进制文件上传 */
|
|
37
39
|
UploadFileBinary(formData: FormData): Promise<AxiosResponse<ApiResponse>>;
|
|
38
40
|
/** 设置/删除代理IP */
|
package/dist/api/ToolsApi.js
CHANGED
|
@@ -67,6 +67,10 @@ class ToolsApi {
|
|
|
67
67
|
UploadFile(body) {
|
|
68
68
|
return axiosInstance_1.axiosInstance.post('/Tools/UploadFile', body);
|
|
69
69
|
}
|
|
70
|
+
/** 文件上传 */
|
|
71
|
+
UploadAppAttachApi(body) {
|
|
72
|
+
return axiosInstance_1.axiosInstance.post('/Tools/UploadAppAttachApi', body);
|
|
73
|
+
}
|
|
70
74
|
/** 二进制文件上传 */
|
|
71
75
|
UploadFileBinary(formData) {
|
|
72
76
|
return axiosInstance_1.axiosInstance.post('/Tools/UploadFileBinary', formData, {
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare class WxBot extends EventEmitter {
|
|
|
61
61
|
clearCache(): Promise<void>;
|
|
62
62
|
login(): Promise<void>;
|
|
63
63
|
start(): Promise<void>;
|
|
64
|
+
loginTwice(): Promise<boolean>;
|
|
64
65
|
static get Contact(): typeof Contact;
|
|
65
66
|
get Contact(): typeof Contact;
|
|
66
67
|
static get Room(): typeof Room;
|
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ class WxBot extends events_1.EventEmitter {
|
|
|
192
192
|
}
|
|
193
193
|
const data = response.data;
|
|
194
194
|
this.uuid = data.Data.Uuid;
|
|
195
|
-
const match = data.Data.QrUrl.match(/[?&]
|
|
195
|
+
const match = data.Data.QrUrl.match(/[?&]url=([^&]+)/);
|
|
196
196
|
if (match && match[1]) {
|
|
197
197
|
const qrLink = decodeURIComponent(match[1]);
|
|
198
198
|
this.emit('scan', {
|
|
@@ -661,6 +661,27 @@ class WxBot extends events_1.EventEmitter {
|
|
|
661
661
|
}
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
|
+
loginTwice() {
|
|
665
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
666
|
+
const config = yield config_service_1.configService.get();
|
|
667
|
+
if (!config) {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
const resp = yield MsgApi_1.msgApi.Sync({
|
|
671
|
+
"Wxid": config === null || config === void 0 ? void 0 : config.wxid,
|
|
672
|
+
"Scene": 0,
|
|
673
|
+
"Synckey": ""
|
|
674
|
+
});
|
|
675
|
+
yield LoginApi_1.loginApi.LoginTwiceAutoAuth(config === null || config === void 0 ? void 0 : config.wxid);
|
|
676
|
+
if (yield this.checkSyncLoginStatus(resp.data, config === null || config === void 0 ? void 0 : config.wxid)) {
|
|
677
|
+
yield this.loginSuccess(config.wxid);
|
|
678
|
+
return true;
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
return false;
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}
|
|
664
685
|
static get Contact() {
|
|
665
686
|
return Contact_1.Contact;
|
|
666
687
|
}
|