@iflyrpa/actions 4.0.0-beta.2 → 4.0.0-beta.6
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/bundle.js +160 -57
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +128 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5434,7 +5434,7 @@ function __webpack_require__(moduleId) {
|
|
|
5434
5434
|
return module;
|
|
5435
5435
|
};
|
|
5436
5436
|
})();
|
|
5437
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.0.0-beta.
|
|
5437
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.0-beta.5"}');
|
|
5438
5438
|
var dist = __webpack_require__("../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js");
|
|
5439
5439
|
async function ProxyAgent(task, ip, adr, accountId, refresh) {
|
|
5440
5440
|
const http = new Http({
|
|
@@ -5524,6 +5524,13 @@ class Http {
|
|
|
5524
5524
|
}
|
|
5525
5525
|
};
|
|
5526
5526
|
if (foundError) Object.assign(errorResponse, foundError);
|
|
5527
|
+
if (error.response?.status === 403) {
|
|
5528
|
+
this.logger?.warn(`[403 详细信息] URL: ${error.config?.url}`);
|
|
5529
|
+
this.logger?.warn(`[403 响应头] ${JSON.stringify(error.response?.headers || {})}`);
|
|
5530
|
+
this.logger?.warn(`[403 响应体] ${JSON.stringify(error.response?.data || null)}`);
|
|
5531
|
+
const verifyDecision = error.response?.headers?.["x-tt-verify-passport-decision"];
|
|
5532
|
+
if (verifyDecision) this.logger?.warn(`[403 验证决策] x-tt-verify-passport-decision: ${verifyDecision}`);
|
|
5533
|
+
}
|
|
5527
5534
|
if (error.response?.data) {
|
|
5528
5535
|
if ("object" == typeof error.response.data) {
|
|
5529
5536
|
const serverError = error.response.data;
|
|
@@ -14402,21 +14409,13 @@ const mock_mockAction = async (task, params)=>{
|
|
|
14402
14409
|
console.log("拦截器收到响应:", JSON.stringify(response.data));
|
|
14403
14410
|
task.logger.info(`拦截器收到响应response.headers: ${JSON.stringify(response.headers)} `);
|
|
14404
14411
|
task.logger.info(`拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
14405
|
-
task.logger.info(`拦截器收到响应response.data类型: ${typeof response.data}, 值: ${JSON.stringify(response.data)}`);
|
|
14406
14412
|
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
14407
|
-
task.logger.info(`解析后的decision: ${JSON.stringify(decision)}`);
|
|
14408
14413
|
if (needsVerification(decision)) {
|
|
14409
|
-
task.logger.info(
|
|
14410
|
-
task.logger.info("拦截器即将return,不抛错");
|
|
14411
|
-
return;
|
|
14412
|
-
}
|
|
14413
|
-
task.logger.info("不需要验证,继续检查response.data");
|
|
14414
|
-
if (!response || !response.data) {
|
|
14415
|
-
task.logger.info("response或response.data为空,拦截器return");
|
|
14414
|
+
task.logger.info(`需要验证: ${JSON.stringify(decision)}`);
|
|
14416
14415
|
return;
|
|
14417
14416
|
}
|
|
14417
|
+
if (!response || !response.data) return;
|
|
14418
14418
|
const responseData = response.data;
|
|
14419
|
-
task.logger.info(`responseData.status_code: ${responseData?.status_code}`);
|
|
14420
14419
|
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
14421
14420
|
const errorCode = 4 === responseData.status_code ? 500 : responseData.status_code;
|
|
14422
14421
|
if (4 === responseData.status_code) task.logger.warn(`抖音服务器错误 status_code: 4,映射为 500 触发重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
@@ -14513,9 +14512,33 @@ const mock_mockAction = async (task, params)=>{
|
|
|
14513
14512
|
retryDelay: 2000
|
|
14514
14513
|
});
|
|
14515
14514
|
task.logger.info("========== api调用完成 ==========");
|
|
14516
|
-
task.logger.info(`
|
|
14517
|
-
|
|
14518
|
-
|
|
14515
|
+
task.logger.info(`decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
14516
|
+
if (needsVerification(decision)) {
|
|
14517
|
+
const details = [
|
|
14518
|
+
publishResult.status_msg,
|
|
14519
|
+
decision?.verify_title,
|
|
14520
|
+
decision?.verify_desc
|
|
14521
|
+
].filter(Boolean).join(" ");
|
|
14522
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
14523
|
+
task.logger.warn(`TaskId:${task.taskId},检测到需要验证,准备返回验证信息`);
|
|
14524
|
+
let decisionObj = {};
|
|
14525
|
+
if (decision) decisionObj = decision;
|
|
14526
|
+
const mockData = {
|
|
14527
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
14528
|
+
error: message,
|
|
14529
|
+
result: {
|
|
14530
|
+
...decisionObj,
|
|
14531
|
+
data: decision,
|
|
14532
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
14533
|
+
}
|
|
14534
|
+
};
|
|
14535
|
+
await updateTaskState?.(mockData);
|
|
14536
|
+
return {
|
|
14537
|
+
code: 0,
|
|
14538
|
+
data: mockData,
|
|
14539
|
+
message: "操作成功"
|
|
14540
|
+
};
|
|
14541
|
+
}
|
|
14519
14542
|
task.logger.info("不需要验证,继续正常流程");
|
|
14520
14543
|
reportLogger({
|
|
14521
14544
|
token: params.huiwenToken || "",
|
|
@@ -14534,10 +14557,13 @@ const mock_mockAction = async (task, params)=>{
|
|
|
14534
14557
|
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
14535
14558
|
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
14536
14559
|
if (!isSuccess) {
|
|
14560
|
+
let decisionObj = {};
|
|
14561
|
+
if (decision) decisionObj = decision;
|
|
14537
14562
|
await updateTaskState?.({
|
|
14538
14563
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
14539
14564
|
error: message,
|
|
14540
14565
|
result: {
|
|
14566
|
+
...decisionObj,
|
|
14541
14567
|
data: decision,
|
|
14542
14568
|
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
14543
14569
|
}
|
|
@@ -15212,15 +15238,41 @@ const rpaAction_Server = async (task, params)=>{
|
|
|
15212
15238
|
}
|
|
15213
15239
|
task.logger?.info("准备发布...");
|
|
15214
15240
|
await page.waitForTimeout(1000);
|
|
15215
|
-
const
|
|
15241
|
+
const result = await new Promise((resolve, reject)=>{
|
|
15216
15242
|
const handleResponse = async (res)=>{
|
|
15217
15243
|
if (res.url().includes("/web/api/media/aweme/create_v2")) {
|
|
15218
15244
|
task.logger?.info("匹配到发布接口响应");
|
|
15245
|
+
let decision = null;
|
|
15246
|
+
try {
|
|
15247
|
+
const headers = await res.allHeaders();
|
|
15248
|
+
decision = parseVerifyPassportDecision(headers["x-tt-verify-passport-decision"]);
|
|
15249
|
+
} catch (error) {
|
|
15250
|
+
task.logger?.warn(`解析验证决策头失败: ${error}`);
|
|
15251
|
+
}
|
|
15219
15252
|
const jsonResponse = await res.json();
|
|
15220
15253
|
task.logger?.info(`发布接口响应数据: ${JSON.stringify(jsonResponse)}`);
|
|
15221
15254
|
page.off("response", handleResponse);
|
|
15222
|
-
if (
|
|
15223
|
-
|
|
15255
|
+
if (needsVerification(decision)) {
|
|
15256
|
+
task.logger?.warn("检测到需要二次验证,文章未真正发布");
|
|
15257
|
+
resolve({
|
|
15258
|
+
itemId: "",
|
|
15259
|
+
decision
|
|
15260
|
+
});
|
|
15261
|
+
return;
|
|
15262
|
+
}
|
|
15263
|
+
if (jsonResponse?.status_code !== 0) {
|
|
15264
|
+
reject(new Error(jsonResponse?.status_msg || "发布失败"));
|
|
15265
|
+
return;
|
|
15266
|
+
}
|
|
15267
|
+
const itemId = jsonResponse?.data?.item_id || jsonResponse?.item_id || "";
|
|
15268
|
+
if (!itemId) {
|
|
15269
|
+
reject(new Error(jsonResponse?.status_msg || "发布异常:未返回作品ID,文章可能未真正发布"));
|
|
15270
|
+
return;
|
|
15271
|
+
}
|
|
15272
|
+
resolve({
|
|
15273
|
+
itemId,
|
|
15274
|
+
decision: null
|
|
15275
|
+
});
|
|
15224
15276
|
}
|
|
15225
15277
|
};
|
|
15226
15278
|
page.on("response", handleResponse);
|
|
@@ -15242,20 +15294,42 @@ const rpaAction_Server = async (task, params)=>{
|
|
|
15242
15294
|
await page.close();
|
|
15243
15295
|
return null;
|
|
15244
15296
|
});
|
|
15245
|
-
if (!
|
|
15297
|
+
if (!result) return {
|
|
15246
15298
|
code: 414,
|
|
15247
15299
|
message: "发布失败",
|
|
15248
15300
|
data: ""
|
|
15249
15301
|
};
|
|
15250
|
-
|
|
15302
|
+
if (needsVerification(result.decision)) {
|
|
15303
|
+
const decision = result.decision;
|
|
15304
|
+
const details = [
|
|
15305
|
+
decision?.verify_title,
|
|
15306
|
+
decision?.verify_desc
|
|
15307
|
+
].filter(Boolean).join(" ");
|
|
15308
|
+
const message = `发布失败,需要二次验证${details ? `:${details}` : ""}`;
|
|
15309
|
+
task.logger?.warn(message);
|
|
15310
|
+
await updateTaskState?.({
|
|
15311
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
15312
|
+
error: message,
|
|
15313
|
+
result: {
|
|
15314
|
+
data: decision
|
|
15315
|
+
}
|
|
15316
|
+
});
|
|
15317
|
+
await page.close();
|
|
15318
|
+
return {
|
|
15319
|
+
code: 414,
|
|
15320
|
+
message,
|
|
15321
|
+
data: ""
|
|
15322
|
+
};
|
|
15323
|
+
}
|
|
15324
|
+
task.logger?.info(`✓ 发布成功,item_id: ${result.itemId}`);
|
|
15251
15325
|
await updateTaskState?.({
|
|
15252
15326
|
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
15253
15327
|
result: {
|
|
15254
|
-
response
|
|
15328
|
+
response: result.itemId
|
|
15255
15329
|
}
|
|
15256
15330
|
});
|
|
15257
15331
|
await page.close();
|
|
15258
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(
|
|
15332
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(result.itemId);
|
|
15259
15333
|
};
|
|
15260
15334
|
const DouyinPublishParamsSchema = ActionCommonParamsSchema.extend({
|
|
15261
15335
|
title: schemas_string(),
|
|
@@ -16035,26 +16109,26 @@ async function getToutiaoData(_task, params) {
|
|
|
16035
16109
|
const http = new Http({
|
|
16036
16110
|
headers: {
|
|
16037
16111
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16038
|
-
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
16112
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
|
|
16113
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
|
|
16114
|
+
}
|
|
16115
|
+
});
|
|
16116
|
+
const totalData = await http.api({
|
|
16117
|
+
method: "get",
|
|
16118
|
+
url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
|
|
16119
|
+
params: {
|
|
16120
|
+
app_id: 1231
|
|
16121
|
+
}
|
|
16122
|
+
});
|
|
16123
|
+
await new Promise((r)=>setTimeout(r, 1000));
|
|
16124
|
+
const contentDataYesterday = await http.api({
|
|
16125
|
+
method: "get",
|
|
16126
|
+
url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
|
|
16127
|
+
params: {
|
|
16128
|
+
type: 0,
|
|
16129
|
+
app_id: 1231
|
|
16039
16130
|
}
|
|
16040
16131
|
});
|
|
16041
|
-
const [totalData, contentDataYesterday] = await Promise.all([
|
|
16042
|
-
http.api({
|
|
16043
|
-
method: "get",
|
|
16044
|
-
url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
|
|
16045
|
-
params: {
|
|
16046
|
-
app_id: 1231
|
|
16047
|
-
}
|
|
16048
|
-
}),
|
|
16049
|
-
http.api({
|
|
16050
|
-
method: "get",
|
|
16051
|
-
url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
|
|
16052
|
-
params: {
|
|
16053
|
-
type: 0,
|
|
16054
|
-
app_id: 1231
|
|
16055
|
-
}
|
|
16056
|
-
})
|
|
16057
|
-
]);
|
|
16058
16132
|
const isSuccess = !!(totalData?.data?.statistic && contentDataYesterday?.author_stat);
|
|
16059
16133
|
if (!isSuccess || !totalData?.data || !contentDataYesterday?.author_stat) return types_errorResponse(totalData?.message || contentDataYesterday?.message || "头条号数据获取失败,请检查Cookie是否有效", 414);
|
|
16060
16134
|
const ttData = {
|
|
@@ -20227,8 +20301,10 @@ const toutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
20227
20301
|
tuwen_wtt_trans_flag: params.settingInfo?.toutiaoTransWtt ? "2" : "0",
|
|
20228
20302
|
info_source: sourceData,
|
|
20229
20303
|
...location ? {
|
|
20230
|
-
|
|
20231
|
-
|
|
20304
|
+
manual_selected_city: JSON.stringify({
|
|
20305
|
+
city: location.label,
|
|
20306
|
+
city_code: location.value
|
|
20307
|
+
})
|
|
20232
20308
|
} : null,
|
|
20233
20309
|
...params.settingInfo?.toutiaoCollectionId ? {
|
|
20234
20310
|
want_join_collection_id: params.settingInfo.toutiaoCollectionId
|
|
@@ -20278,6 +20354,12 @@ const toutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
|
20278
20354
|
claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
|
|
20279
20355
|
};
|
|
20280
20356
|
task._timerRecord.PrePublish = Date.now();
|
|
20357
|
+
task.logger.info(`[toutiaoPublish] ${"draft" === params.saveType ? "同步草稿" : "发布文章"}参数`, {
|
|
20358
|
+
saveType: params.saveType,
|
|
20359
|
+
title: params.title,
|
|
20360
|
+
extra: extraData,
|
|
20361
|
+
publishData
|
|
20362
|
+
});
|
|
20281
20363
|
const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
20282
20364
|
let publishOption = {};
|
|
20283
20365
|
if (msToken) {
|
|
@@ -21473,8 +21555,8 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
21473
21555
|
headers
|
|
21474
21556
|
});
|
|
21475
21557
|
const proxyHttp = new Http(...args);
|
|
21476
|
-
|
|
21477
|
-
const responseData = response
|
|
21558
|
+
const baseRespFinder = (response)=>{
|
|
21559
|
+
const responseData = response?.data;
|
|
21478
21560
|
const msgType = "draft" === params.saveType ? "同步" : "发布";
|
|
21479
21561
|
if (response && responseData?.base_resp && 0 !== responseData.base_resp.ret && !ignoreErrno.includes(responseData.base_resp.ret)) {
|
|
21480
21562
|
const errmsg = weixinPublish_mock_errnoMap[responseData.base_resp.ret] || response.config.defaultErrorMsg || responseData.base_resp.err_msg || `文章${msgType}异常,请稍后重试。`;
|
|
@@ -21484,7 +21566,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
|
|
|
21484
21566
|
data: responseData
|
|
21485
21567
|
};
|
|
21486
21568
|
}
|
|
21487
|
-
}
|
|
21569
|
+
};
|
|
21570
|
+
http.addResponseInterceptor(baseRespFinder);
|
|
21571
|
+
proxyHttp.addResponseInterceptor(baseRespFinder);
|
|
21488
21572
|
await http.api({
|
|
21489
21573
|
method: "get",
|
|
21490
21574
|
url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
|