@iflyrpa/actions 1.1.28 → 1.1.30
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/actions/baijiahaoPublish/index.d.ts +2 -3
- package/dist/actions/getBaijiahaoActivity/index.d.ts +2 -3
- package/dist/actions/getToutiaoConfig/index.d.ts +2 -3
- package/dist/actions/searchToutiaoTopicList/index.d.ts +2 -3
- package/dist/actions/searchXiaohongshuLocation/index.d.ts +2 -3
- package/dist/actions/toutiaoPublish/index.d.ts +2 -3
- package/dist/actions/weitoutiaoPublish/index.d.ts +2 -3
- package/dist/actions/weixinPublish/index.d.ts +2 -3
- package/dist/actions/weixinmpPublish/index.d.ts +2 -3
- package/dist/actions/xiaohongshuPublish/index.d.ts +2 -3
- package/dist/bundle.js +57 -31
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +57 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -31
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { CommonAction
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams } from "../../types";
|
|
3
3
|
interface ActivityData {
|
|
4
4
|
id: string;
|
|
5
5
|
task_name: string;
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
}
|
|
8
|
-
export interface BaijiahaoPublishParams extends
|
|
8
|
+
export interface BaijiahaoPublishParams extends ActiomCommonParams {
|
|
9
9
|
saveType: "draft" | "publish";
|
|
10
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
11
10
|
token: string;
|
|
12
11
|
title: string;
|
|
13
12
|
content: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type CommonAction
|
|
1
|
+
import { type CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams } from "../../types";
|
|
3
|
-
export interface GetBaijiahaoActivityParams extends
|
|
4
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
3
|
+
export interface GetBaijiahaoActivityParams extends ActiomCommonParams {
|
|
5
4
|
token: string;
|
|
6
5
|
}
|
|
7
6
|
export interface ActivityData {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type CommonAction
|
|
1
|
+
import { type CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams, Toutiao } from "../../types";
|
|
3
|
-
export interface GetToutiaoConfigParams extends
|
|
4
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
3
|
+
export interface GetToutiaoConfigParams extends ActiomCommonParams {
|
|
5
4
|
}
|
|
6
5
|
export interface GetToutiaoConfigResult {
|
|
7
6
|
suggestWords: Toutiao.Topic[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type CommonAction
|
|
1
|
+
import { type CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams, Toutiao } from "../../types";
|
|
3
|
-
export interface SearchToutiaoTopicListParams extends
|
|
4
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
3
|
+
export interface SearchToutiaoTopicListParams extends ActiomCommonParams {
|
|
5
4
|
searchValue: string;
|
|
6
5
|
}
|
|
7
6
|
export type PublishAction = CommonAction<SearchToutiaoTopicListParams, Toutiao.Topic[]>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type CommonAction
|
|
1
|
+
import { type CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams, Xiaohongshu } from "../../types";
|
|
3
|
-
export interface searchXiaohongshuLocationParams extends
|
|
4
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
3
|
+
export interface searchXiaohongshuLocationParams extends ActiomCommonParams {
|
|
5
4
|
searchValue: string;
|
|
6
5
|
latitude?: number;
|
|
7
6
|
longitude?: number;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { CommonAction
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams } from "../../types";
|
|
3
3
|
type CoverType = "single" | "multiple" | "no";
|
|
4
|
-
export interface ToutiaoPublishParams extends
|
|
4
|
+
export interface ToutiaoPublishParams extends ActiomCommonParams {
|
|
5
5
|
saveType: "draft" | "publish";
|
|
6
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
7
6
|
title: string;
|
|
8
7
|
content: string;
|
|
9
8
|
settingInfo: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommonAction
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams } from "../../types";
|
|
3
3
|
/**
|
|
4
4
|
* 作品声明
|
|
@@ -11,8 +11,7 @@ import type { ActiomCommonParams } from "../../types";
|
|
|
11
11
|
* 8:健康医疗分享,仅供参考
|
|
12
12
|
*/
|
|
13
13
|
type DeclarationType = 1 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
14
|
-
export interface WeitoutiaoPublishParams extends
|
|
15
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
14
|
+
export interface WeitoutiaoPublishParams extends ActiomCommonParams {
|
|
16
15
|
content: string;
|
|
17
16
|
banners?: string[];
|
|
18
17
|
address?: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { CommonAction
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams } from "../../types";
|
|
3
|
-
export interface WeixinPublishParams extends
|
|
3
|
+
export interface WeixinPublishParams extends ActiomCommonParams {
|
|
4
4
|
saveType: "draft" | "publish";
|
|
5
5
|
token: string | number;
|
|
6
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
7
6
|
title: string;
|
|
8
7
|
content: string;
|
|
9
8
|
uuid?: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { CommonAction
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams } from "../../types";
|
|
3
3
|
export type Source = "ai" | "official" | "fictional" | "personal";
|
|
4
|
-
export interface WeixinmpPublishParams extends
|
|
4
|
+
export interface WeixinmpPublishParams extends ActiomCommonParams {
|
|
5
5
|
token: string | number;
|
|
6
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
7
6
|
banners?: string[];
|
|
8
7
|
title: string;
|
|
9
8
|
content: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommonAction
|
|
1
|
+
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import type { ActiomCommonParams, Xiaohongshu } from "../../types";
|
|
3
3
|
interface FictionalRendition {
|
|
4
4
|
type: "fictional-rendition";
|
|
@@ -14,8 +14,7 @@ interface SourceStatement {
|
|
|
14
14
|
sourceMedia?: string;
|
|
15
15
|
}
|
|
16
16
|
type SelfDeclaration = FictionalRendition | AIGenerated | SourceStatement;
|
|
17
|
-
export interface XiaohongshuPublishParams extends
|
|
18
|
-
cookies: Partial<CookiesSetDetails>[];
|
|
17
|
+
export interface XiaohongshuPublishParams extends ActiomCommonParams {
|
|
19
18
|
banners: string[];
|
|
20
19
|
title: string;
|
|
21
20
|
content: string;
|
package/dist/bundle.js
CHANGED
|
@@ -13000,7 +13000,7 @@ var __webpack_exports__ = {};
|
|
|
13000
13000
|
const action = actions[index];
|
|
13001
13001
|
try {
|
|
13002
13002
|
const currentResult = await action(task, params);
|
|
13003
|
-
if (0 === currentResult.code) return currentResult;
|
|
13003
|
+
if (0 === currentResult.code || 200 === currentResult.code) return currentResult;
|
|
13004
13004
|
task.logger.error(currentResult.message, stringifyError(currentResult.data));
|
|
13005
13005
|
result = currentResult;
|
|
13006
13006
|
} catch (error) {
|
|
@@ -13419,13 +13419,11 @@ var __webpack_exports__ = {};
|
|
|
13419
13419
|
return success(articleId);
|
|
13420
13420
|
};
|
|
13421
13421
|
const baijiahaoPublish = async (task, params)=>{
|
|
13422
|
-
task.logger.info("开始百家号发布");
|
|
13423
13422
|
if ("rpa" === params.actionType) return rpaAction(task, params);
|
|
13424
13423
|
if ("mockApi" === params.actionType) return mockAction(task, params);
|
|
13425
13424
|
return executeAction(mockAction, rpaAction)(task, params);
|
|
13426
13425
|
};
|
|
13427
|
-
const getBaijiahaoActivity = async (
|
|
13428
|
-
task.logger.info("查询百家号活动投稿");
|
|
13426
|
+
const getBaijiahaoActivity = async (_task, params)=>{
|
|
13429
13427
|
const cookies = params.cookies ?? [];
|
|
13430
13428
|
const http = new Http({
|
|
13431
13429
|
headers: {
|
|
@@ -13445,10 +13443,9 @@ var __webpack_exports__ = {};
|
|
|
13445
13443
|
task_type: -1
|
|
13446
13444
|
}
|
|
13447
13445
|
});
|
|
13448
|
-
return success(res
|
|
13446
|
+
return success(res?.data?.list);
|
|
13449
13447
|
};
|
|
13450
|
-
const getToutiaoConfig = async (
|
|
13451
|
-
task.logger.info("获取头条发布配置的话题信息、位置信息和原创首发信息");
|
|
13448
|
+
const getToutiaoConfig = async (_task, params)=>{
|
|
13452
13449
|
const cookies = params.cookies ?? [];
|
|
13453
13450
|
const http = new Http({
|
|
13454
13451
|
headers: {
|
|
@@ -13504,8 +13501,7 @@ var __webpack_exports__ = {};
|
|
|
13504
13501
|
userRights
|
|
13505
13502
|
});
|
|
13506
13503
|
};
|
|
13507
|
-
const searchToutiaoTopicList = async (
|
|
13508
|
-
task.logger.info("搜索头条话题");
|
|
13504
|
+
const searchToutiaoTopicList = async (_task, params)=>{
|
|
13509
13505
|
const http = new Http({
|
|
13510
13506
|
headers: {
|
|
13511
13507
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
@@ -14013,6 +14009,9 @@ var __webpack_exports__ = {};
|
|
|
14013
14009
|
const weixinPublish_mock_errnoMap = {
|
|
14014
14010
|
200003: "微信公众号号登录状态失效,请重新绑定账号后重试。"
|
|
14015
14011
|
};
|
|
14012
|
+
const ignoreErrno = [
|
|
14013
|
+
154019
|
|
14014
|
+
];
|
|
14016
14015
|
const generatorFormData = (data)=>{
|
|
14017
14016
|
const formData = new URLSearchParams();
|
|
14018
14017
|
for (const [key, value] of Object.entries(data))formData.append(key, String(value));
|
|
@@ -14050,7 +14049,7 @@ var __webpack_exports__ = {};
|
|
|
14050
14049
|
});
|
|
14051
14050
|
http.addResponseInterceptor((response)=>{
|
|
14052
14051
|
const responseData = response.data;
|
|
14053
|
-
if (responseData?.base_resp && 0 !== responseData.base_resp.ret) {
|
|
14052
|
+
if (responseData?.base_resp && 0 !== responseData.base_resp.ret && !ignoreErrno.includes(responseData.base_resp.ret)) {
|
|
14054
14053
|
const errmsg = weixinPublish_mock_errnoMap[responseData.base_resp.ret] || response.config.defaultErrorMsg || responseData.base_resp.err_msg || "Unknown error";
|
|
14055
14054
|
return {
|
|
14056
14055
|
code: responseData.base_resp.ret,
|
|
@@ -14180,24 +14179,48 @@ var __webpack_exports__ = {};
|
|
|
14180
14179
|
message: "微信公众号保存草稿成功。"
|
|
14181
14180
|
};
|
|
14182
14181
|
}
|
|
14183
|
-
const
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14182
|
+
const masssendpage = ()=>http.api({
|
|
14183
|
+
method: "get",
|
|
14184
|
+
url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
|
|
14185
|
+
params: {
|
|
14186
|
+
token: params.token,
|
|
14187
|
+
lang: "zh_CN",
|
|
14188
|
+
f: "json",
|
|
14189
|
+
ajax: 1,
|
|
14190
|
+
preview_appmsgid: appMsgId,
|
|
14191
|
+
fingerprint,
|
|
14192
|
+
random: Math.random().toString()
|
|
14193
|
+
},
|
|
14194
|
+
defaultErrorMsg: "创建草稿失败,请稍后重试发布。"
|
|
14195
|
+
});
|
|
14196
|
+
let massSendRes = await masssendpage();
|
|
14197
|
+
if (massSendRes.base_resp?.ret === 154019) {
|
|
14198
|
+
task.logger.info("需要同意群发声明");
|
|
14199
|
+
await http.api({
|
|
14200
|
+
method: "post",
|
|
14201
|
+
url: "https://mp.weixin.qq.com/cgi-bin/setprotocolsign",
|
|
14202
|
+
params: {
|
|
14203
|
+
cgi: "setprotocolsign",
|
|
14204
|
+
lang: "zh_CN",
|
|
14205
|
+
token: params.token
|
|
14206
|
+
},
|
|
14207
|
+
data: generatorFormData({
|
|
14208
|
+
token: params.token,
|
|
14209
|
+
lang: "zh_CN",
|
|
14210
|
+
f: "json",
|
|
14211
|
+
ajax: 1,
|
|
14212
|
+
fingerprint,
|
|
14213
|
+
random: Math.random().toString(),
|
|
14214
|
+
issigned: 1
|
|
14215
|
+
})
|
|
14216
|
+
});
|
|
14217
|
+
massSendRes = await masssendpage();
|
|
14218
|
+
}
|
|
14219
|
+
const { operation_seq, mass_send_left } = massSendRes;
|
|
14197
14220
|
if (mass_send_left < 1) return {
|
|
14198
|
-
code:
|
|
14221
|
+
code: 200,
|
|
14199
14222
|
message: "今日群发次数用尽,请明天再试。",
|
|
14200
|
-
data:
|
|
14223
|
+
data: mass_send_left.toString()
|
|
14201
14224
|
};
|
|
14202
14225
|
await http.api({
|
|
14203
14226
|
method: "post",
|
|
@@ -14368,7 +14391,7 @@ var __webpack_exports__ = {};
|
|
|
14368
14391
|
break;
|
|
14369
14392
|
}
|
|
14370
14393
|
if (i === scanRetryMaxCount - 1) return {
|
|
14371
|
-
code:
|
|
14394
|
+
code: 200,
|
|
14372
14395
|
message: "群发二维码已过期,请重试发布。",
|
|
14373
14396
|
data: ""
|
|
14374
14397
|
};
|
|
@@ -14415,7 +14438,6 @@ var __webpack_exports__ = {};
|
|
|
14415
14438
|
}),
|
|
14416
14439
|
defaultErrorMsg: "文章群发异常,请尝试关闭群发或稍后重试。"
|
|
14417
14440
|
});
|
|
14418
|
-
task.logger.info("微信公众号发布完成。");
|
|
14419
14441
|
return success(appMsgId, "微信公众号发布完成。");
|
|
14420
14442
|
};
|
|
14421
14443
|
const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
|
|
@@ -14600,7 +14622,6 @@ var __webpack_exports__ = {};
|
|
|
14600
14622
|
return success(articleId);
|
|
14601
14623
|
};
|
|
14602
14624
|
const weixinPublish = async (task, params)=>{
|
|
14603
|
-
task.logger.info("开始微信公众号发布");
|
|
14604
14625
|
if ("rpa" === params.actionType) return weixinPublish_rpa_rpaAction(task, params);
|
|
14605
14626
|
if ("mockApi" === params.actionType) return weixinPublish_mock_mockAction(task, params);
|
|
14606
14627
|
return executeAction(weixinPublish_mock_mockAction, weixinPublish_rpa_rpaAction)(task, params);
|
|
@@ -15201,7 +15222,7 @@ var __webpack_exports__ = {};
|
|
|
15201
15222
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
15202
15223
|
};
|
|
15203
15224
|
var package_namespaceObject = {
|
|
15204
|
-
i8: "1.1.
|
|
15225
|
+
i8: "1.1.29"
|
|
15205
15226
|
};
|
|
15206
15227
|
class Action {
|
|
15207
15228
|
constructor(task){
|
|
@@ -15209,12 +15230,17 @@ var __webpack_exports__ = {};
|
|
|
15209
15230
|
}
|
|
15210
15231
|
async bindTask(func, params) {
|
|
15211
15232
|
let responseData;
|
|
15233
|
+
this.task.logger.info(`${func.name} start`);
|
|
15234
|
+
if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
|
|
15212
15235
|
try {
|
|
15213
15236
|
responseData = await func(this.task, params);
|
|
15214
15237
|
} catch (error) {
|
|
15215
15238
|
responseData = Http.handleApiError(error);
|
|
15216
15239
|
}
|
|
15217
|
-
if (0 !== responseData.code)
|
|
15240
|
+
if (0 !== responseData.code) {
|
|
15241
|
+
this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data));
|
|
15242
|
+
this.task.logger.info(`${func.name} action failed`);
|
|
15243
|
+
} else this.task.logger.info(`${func.name} action success`);
|
|
15218
15244
|
return responseData;
|
|
15219
15245
|
}
|
|
15220
15246
|
searchToutiaoTopicList(params) {
|