@iflyrpa/actions 1.2.11-beta.2 → 1.2.11-beta.4

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.
@@ -19,6 +19,11 @@ export interface BaijiahaoPublishParams extends ActiomCommonParams {
19
19
  baijiahaoMultCover: string[];
20
20
  baijiahaoVerticalCover: string;
21
21
  baijiahaoActivity: ActivityData[];
22
+ baijiahaoPublishConf?: {
23
+ confName: string;
24
+ isChecked: boolean;
25
+ }[];
26
+ baijiahaoEvent2News: boolean;
22
27
  baijiahaoSelectActivityCache: string[];
23
28
  timer?: number;
24
29
  };
@@ -0,0 +1,13 @@
1
+ import { type CommonAction } from "@iflyrpa/share";
2
+ import type { ActiomCommonParams } from "../../types";
3
+ export interface GetBaijiahaoConfigParams extends ActiomCommonParams {
4
+ token: string;
5
+ }
6
+ export interface ConfigData {
7
+ id: string;
8
+ name: string;
9
+ detail: string;
10
+ is_enable: number;
11
+ }
12
+ export type PublishAction = CommonAction<GetBaijiahaoConfigParams, ConfigData[]>;
13
+ export declare const getBaijiahaoConfig: PublishAction;
@@ -0,0 +1,7 @@
1
+ import { type CommonAction } from "@iflyrpa/share";
2
+ import type { ActiomCommonParams, Toutiao } from "../../types";
3
+ export interface SearchToutiaoLocationParams extends ActiomCommonParams {
4
+ placeName: string;
5
+ }
6
+ export type PublishAction = CommonAction<SearchToutiaoLocationParams, Toutiao.CityPoi[]>;
7
+ export declare const searchToutiaoLocation: PublishAction;
@@ -0,0 +1,7 @@
1
+ import { type CommonAction } from "@iflyrpa/share";
2
+ import type { ActiomCommonParams, Toutiao } from "../../types";
3
+ export interface SearchToutiaoUserIDParams extends ActiomCommonParams {
4
+ UserName: string;
5
+ }
6
+ export type PublishAction = CommonAction<SearchToutiaoUserIDParams, Toutiao.SuggestWords[]>;
7
+ export declare const searchToutiaoUserInfo: PublishAction;
@@ -12,6 +12,21 @@ export interface ToutiaoPublishParams extends ActiomCommonParams {
12
12
  toutiaoMultCover: string[];
13
13
  toutiaoAd: string;
14
14
  toutiaoOriginal: string;
15
+ toutiaoExclusive?: number;
16
+ toutiaoClaim?: {
17
+ type: number;
18
+ source_author_uid?: string;
19
+ source_author_name?: string;
20
+ time_format?: string;
21
+ position?: {
22
+ position: string;
23
+ city: string;
24
+ longitude: number;
25
+ latitude: number;
26
+ type_code: string;
27
+ poi_id: string;
28
+ };
29
+ };
15
30
  toutiaoLocation?: {
16
31
  label: string;
17
32
  value: string;
package/dist/bundle.js CHANGED
@@ -14398,13 +14398,15 @@ var __webpack_exports__ = {};
14398
14398
  is_checked: 1
14399
14399
  }
14400
14400
  ] : [],
14401
- ...isAi ? [
14402
- {
14403
- id: "aigc_bjh_status",
14404
- is_checked: 1
14405
- }
14406
- ] : []
14401
+ ...params.settingInfo.baijiahaoPublishConf?.map((item)=>({
14402
+ id: item.confName,
14403
+ is_checked: item.isChecked ? 1 : 0
14404
+ })) || []
14407
14405
  ];
14406
+ if (isAi && !activity_list.some((item)=>'aigc_bjh_status' in item)) activity_list.push({
14407
+ id: 'aigc_bjh_status',
14408
+ is_checked: 1
14409
+ });
14408
14410
  const publishData = {
14409
14411
  title: params.settingInfo.baijiahaoTitle,
14410
14412
  content,
@@ -14420,6 +14422,7 @@ var __webpack_exports__ = {};
14420
14422
  usingImgFilter: "false",
14421
14423
  source: "upload",
14422
14424
  cover_source: "upload",
14425
+ event2news: params.settingInfo?.baijiahaoEvent2News ? 2 : 0,
14423
14426
  activity_list
14424
14427
  };
14425
14428
  params.settingInfo.timer && (publishData['timer_time'] = params.settingInfo.timer);
@@ -14527,12 +14530,17 @@ var __webpack_exports__ = {};
14527
14530
  await abstractFormItem.click();
14528
14531
  await abstractFormItem.fill(params.settingInfo.baijiahaoAbstract);
14529
14532
  const isAi = params.settingInfo.baijiahaoIsAi.includes("isAi");
14530
- if (isAi) {
14531
- const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
14532
- await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
14533
- hasText: "AI创作声明"
14534
- }).click();
14533
+ const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
14534
+ if (isAi) await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
14535
+ hasText: "AI创作声明"
14536
+ }).click();
14537
+ if (params.settingInfo.baijiahaoPublishConf) for (const item of params.settingInfo.baijiahaoPublishConf){
14538
+ const _settingFormItem = settingFormItem.locator("label.cheetah-checkbox-wrapper").locator(`span.${item.confName}`);
14539
+ if (await _settingFormItem.isChecked() !== item.isChecked) await _settingFormItem.click();
14540
+ await page.waitForTimeout(200);
14535
14541
  }
14542
+ const enent2NewsBtn = page.locator("input#event2news");
14543
+ if (await enent2NewsBtn.isVisible() && params.settingInfo.baijiahaoEvent2News) await enent2NewsBtn.click();
14536
14544
  if (params.settingInfo.baijiahaoActivity.length > 0 && params.settingInfo.baijiahaoSelectActivityCache.length > 0) {
14537
14545
  const activity = params.settingInfo.baijiahaoActivity.filter((it)=>params.settingInfo.baijiahaoSelectActivityCache.includes(it.id));
14538
14546
  if (activity.length > 0) {
@@ -14627,6 +14635,7 @@ var __webpack_exports__ = {};
14627
14635
  hasText: /^发布/
14628
14636
  }).locator("button").click();
14629
14637
  });
14638
+ await page.waitForTimeout(200000);
14630
14639
  await page.close();
14631
14640
  return success(articleId, articleId ? "发布成功" : message);
14632
14641
  };
@@ -14713,6 +14722,28 @@ var __webpack_exports__ = {};
14713
14722
  userRights
14714
14723
  });
14715
14724
  };
14725
+ const getBaijiahaoConfig = async (_task, params)=>{
14726
+ const cookies = params.cookies ?? [];
14727
+ const http = new Http({
14728
+ headers: {
14729
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
14730
+ token: params.token
14731
+ }
14732
+ });
14733
+ const res = await http.api({
14734
+ method: "get",
14735
+ url: "https://baijiahao.baidu.com/pcui/article/edit",
14736
+ params: {
14737
+ type: "news"
14738
+ }
14739
+ });
14740
+ return success(res?.data?.article.activity_list.map((_item)=>({
14741
+ id: _item.id,
14742
+ name: _item.name,
14743
+ detail: _item.detail,
14744
+ is_enable: _item.is_enable
14745
+ })) ?? [], "获取头条发布配置项成功");
14746
+ };
14716
14747
  const searchToutiaoTopicList = async (_task, params)=>{
14717
14748
  const http = new Http({
14718
14749
  headers: {
@@ -14735,6 +14766,72 @@ var __webpack_exports__ = {};
14735
14766
  return success([]);
14736
14767
  }
14737
14768
  };
14769
+ const searchToutiaoLocation = async (_task, params)=>{
14770
+ const http = new Http({
14771
+ headers: {
14772
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
14773
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
14774
+ biz: 1231
14775
+ }
14776
+ });
14777
+ try {
14778
+ const res = await http.api({
14779
+ method: "post",
14780
+ url: "https://mp.toutiao.com/poi/api/searchplace",
14781
+ data: {
14782
+ appid: 1231,
14783
+ device: 2,
14784
+ keywords: params.placeName,
14785
+ language: "zh-CN",
14786
+ location: "-1,-1",
14787
+ offset: 20,
14788
+ page: 1,
14789
+ region: "CN",
14790
+ scenario: "TIPS",
14791
+ timestamp: Math.floor(Date.now() / 1000)
14792
+ }
14793
+ });
14794
+ if (200 === res.code) return success(res.data.poi.map((item)=>({
14795
+ position: item.name,
14796
+ city: item.city,
14797
+ longitude: item.longitude,
14798
+ latitude: item.latitude,
14799
+ type_code: item.type_code,
14800
+ poi_id: item.id
14801
+ })));
14802
+ return success([]);
14803
+ } catch (error) {
14804
+ return success([]);
14805
+ }
14806
+ };
14807
+ const searchToutiaoUserInfo = async (_task, params)=>{
14808
+ const http = new Http({
14809
+ headers: {
14810
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
14811
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
14812
+ }
14813
+ });
14814
+ try {
14815
+ const res = await http.api({
14816
+ method: "get",
14817
+ url: "https://mp.toutiao.com/ugc/publish/post/v1/suggest/",
14818
+ params: {
14819
+ words: params.UserName,
14820
+ language: "zh",
14821
+ app_name: "toutiao_mp"
14822
+ }
14823
+ });
14824
+ if (0 === res.err_no) return success(res.data.suggest.map((item)=>({
14825
+ user_id: item.user.info.user_id,
14826
+ name: item.user.info.name,
14827
+ avatar_url: item.user.info.avatar_url,
14828
+ followers_count: item.user.relation_count.followers_count
14829
+ })), '搜索成功');
14830
+ return success([]);
14831
+ } catch (error) {
14832
+ return success([]);
14833
+ }
14834
+ };
14738
14835
  const searchXiaohongshuLocation = async (_task, params)=>{
14739
14836
  const http = new Http({
14740
14837
  headers: {
@@ -14822,7 +14919,7 @@ var __webpack_exports__ = {};
14822
14919
  return error || ("draft" === saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。");
14823
14920
  };
14824
14921
  const mock_mockAction = async (task, params)=>{
14825
- const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal } = params.settingInfo;
14922
+ const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
14826
14923
  const tmpCachePath = task.getTmpPath();
14827
14924
  const http = new Http({
14828
14925
  headers: {
@@ -14878,23 +14975,27 @@ var __webpack_exports__ = {};
14878
14975
  toutiaoSingleCover
14879
14976
  ] : "multiple" === toutiaoCoverType ? toutiaoMultCover : [];
14880
14977
  const coverRes = await uploadImages(coverUrl);
14881
- const isSingleTitle = "single" === params.settingInfo.toutiaoTitleType;
14882
14978
  const location = params.settingInfo.toutiaoLocation;
14883
14979
  const topics = params.settingInfo.toutiaoTopic || [];
14884
- const multiTitleData = params.settingInfo.subTitles.map((title)=>({
14885
- id: "0",
14886
- visibility_level: 0,
14887
- source: "author",
14888
- old_source: "author",
14889
- text: title,
14890
- version: "author",
14891
- ai_title: ""
14892
- }));
14893
14980
  const topicContent = topics.map((topic)=>`<p><a class="tteditor-forum" data-name="${topic.word}" data-id="${topic.id}" data-concern-id="${topic.id}">#${topic.word}#</a ></p >`).join("");
14981
+ let sourceData = {
14982
+ source_type: toutiaoClaim ? toutiaoClaim.type : 5
14983
+ };
14984
+ if (toutiaoClaim && 1 === toutiaoClaim.type) {
14985
+ if (!toutiaoClaim?.source_author_uid) return {
14986
+ code: 500,
14987
+ message: "请填写作者ID",
14988
+ data: ""
14989
+ };
14990
+ sourceData = {
14991
+ ...sourceData,
14992
+ source_author_uid: toutiaoClaim.source_author_uid,
14993
+ time_format: toutiaoClaim.time_format,
14994
+ position: toutiaoClaim.position
14995
+ };
14996
+ }
14894
14997
  const extraData = {
14895
14998
  content_word_cnt: params.settingInfo.cntWord,
14896
- is_multi_title: isSingleTitle ? 0 : 1,
14897
- sub_titles: isSingleTitle ? [] : multiTitleData,
14898
14999
  gd_ext: {
14899
15000
  entrance: "",
14900
15001
  from_page: "publisher_mp",
@@ -14903,12 +15004,7 @@ var __webpack_exports__ = {};
14903
15004
  is_message: 0
14904
15005
  },
14905
15006
  tuwen_wtt_trans_flag: "0",
14906
- info_source: {
14907
- source_type: 5,
14908
- source_link: "",
14909
- time_format: "",
14910
- position: {}
14911
- },
15007
+ info_source: sourceData,
14912
15008
  ...location ? {
14913
15009
  city: location.label,
14914
15010
  city_code: location.value
@@ -14955,8 +15051,7 @@ var __webpack_exports__ = {};
14955
15051
  }
14956
15052
  }))),
14957
15053
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
14958
- claim_origin: toutiaoOriginal.includes("original") ? 1 : 0,
14959
- claim_exclusive: toutiaoOriginal.includes("exclusive") ? 1 : 0
15054
+ claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal.includes("exclusive") ? 1 : 0
14960
15055
  };
14961
15056
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
14962
15057
  let publishOption = {};
@@ -15125,11 +15220,38 @@ var __webpack_exports__ = {};
15125
15220
  }).locator("xpath=..");
15126
15221
  const isAdOptionVisible = await adContainer.isVisible();
15127
15222
  if (isAdOptionVisible) await adContainer.locator(`label.byte-radio:has(input[value="${getAddTypeValue(params.settingInfo.toutiaoAd)}"])`).click();
15128
- if (params.settingInfo.toutiaoOriginal.includes("exclusive")) {
15129
- const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
15130
- hasText: "声明首发"
15131
- }).locator("xpath=..");
15132
- exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").click();
15223
+ const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
15224
+ hasText: "声明首发"
15225
+ }).locator("xpath=..");
15226
+ if (params.settingInfo.toutiaoOriginal.includes("exclusive") || params.settingInfo.toutiaoExclusive) exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").check();
15227
+ else exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").uncheck();
15228
+ let claim = params.settingInfo.toutiaoClaim ? params.settingInfo.toutiaoClaim.type : 5;
15229
+ switch(claim){
15230
+ case 3:
15231
+ await page.locator(".source-wrap .byte-checkbox", {
15232
+ hasText: "引用AI"
15233
+ }).locator(".byte-checkbox-mask").check();
15234
+ break;
15235
+ case 4:
15236
+ await page.locator(".source-wrap .byte-checkbox", {
15237
+ hasText: "取材网络"
15238
+ }).locator(".byte-checkbox-mask").check();
15239
+ break;
15240
+ case 5:
15241
+ await page.locator(".source-wrap .byte-checkbox", {
15242
+ hasText: "个人观点,仅供参考"
15243
+ }).locator(".byte-checkbox-mask").check();
15244
+ break;
15245
+ case 6:
15246
+ await page.locator(".source-wrap .byte-checkbox", {
15247
+ hasText: "虚构演绎,故事经历"
15248
+ }).locator(".byte-checkbox-mask").check();
15249
+ break;
15250
+ default:
15251
+ await page.locator(".source-wrap .byte-checkbox", {
15252
+ hasText: "个人观点,仅供参考"
15253
+ }).locator(".byte-checkbox-mask").check();
15254
+ break;
15133
15255
  }
15134
15256
  const articleId = await new Promise(async (resolve)=>{
15135
15257
  const handleResponse = async (response)=>{
@@ -15141,7 +15263,7 @@ var __webpack_exports__ = {};
15141
15263
  }
15142
15264
  };
15143
15265
  page.on("response", handleResponse);
15144
- if (params.settingInfo.timer) {
15266
+ if (params.settingInfo.timer && "publish" == params.saveType) {
15145
15267
  await page.locator(".publish-footer button").filter({
15146
15268
  hasText: "定时发布"
15147
15269
  }).click();
@@ -15187,7 +15309,7 @@ var __webpack_exports__ = {};
15187
15309
  }).click();
15188
15310
  }
15189
15311
  await page.close();
15190
- return success(articleId);
15312
+ return success(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
15191
15313
  };
15192
15314
  const COVER_TYPE = {
15193
15315
  no: 1,
@@ -15973,7 +16095,7 @@ var __webpack_exports__ = {};
15973
16095
  f: "json",
15974
16096
  ajax: 1,
15975
16097
  is_release_publish_page: params.masssend ? 0 : 1,
15976
- send_time: 0,
16098
+ send_time: params.settingInfo.timer ? params.settingInfo.timer : 0,
15977
16099
  random: Math.random().toString()
15978
16100
  })
15979
16101
  });
@@ -16127,7 +16249,11 @@ var __webpack_exports__ = {};
16127
16249
  t: "ajax-response",
16128
16250
  token: params.token,
16129
16251
  lang: "zh_CN",
16130
- ...params.masssend ? {} : {
16252
+ ...params.masssend ? {
16253
+ ...params.settingInfo.timer ? {
16254
+ action: "time_send"
16255
+ } : {}
16256
+ } : {
16131
16257
  is_release_publish_page: 1
16132
16258
  }
16133
16259
  },
@@ -17279,7 +17405,7 @@ var __webpack_exports__ = {};
17279
17405
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
17280
17406
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
17281
17407
  };
17282
- var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.1"}');
17408
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.3"}');
17283
17409
  class Action {
17284
17410
  constructor(task){
17285
17411
  this.task = task;
@@ -17315,9 +17441,18 @@ var __webpack_exports__ = {};
17315
17441
  BjhFansExport(params) {
17316
17442
  return this.bindTask(BjhFansExport, params);
17317
17443
  }
17444
+ searchToutiaoUserID(params) {
17445
+ return this.bindTask(searchToutiaoUserInfo, params);
17446
+ }
17447
+ searchToutiaoLocation(params) {
17448
+ return this.bindTask(searchToutiaoLocation, params);
17449
+ }
17318
17450
  getToutiaoConfig(params) {
17319
17451
  return this.bindTask(getToutiaoConfig, params);
17320
17452
  }
17453
+ getBaijiahaoConfig(params) {
17454
+ return this.bindTask(getBaijiahaoConfig, params);
17455
+ }
17321
17456
  baijiahaoPublish(params) {
17322
17457
  return this.bindTask(baijiahaoPublish, params);
17323
17458
  }