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

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/index.d.ts CHANGED
@@ -2,7 +2,10 @@ import type { AutomateTask, ResponseData } from "@iflyrpa/share";
2
2
  import { type BaijiahaoPublishParams } from "./actions/baijiahaoPublish";
3
3
  import { type GetBaijiahaoActivityParams } from "./actions/getBaijiahaoActivity";
4
4
  import { type GetToutiaoConfigParams } from "./actions/getToutiaoConfig";
5
+ import { type GetBaijiahaoConfigParams } from "./actions/getBaijiaohaoConfig";
5
6
  import { type SearchToutiaoTopicListParams } from "./actions/searchToutiaoTopicList";
7
+ import { type SearchToutiaoLocationParams } from "./actions/searchToutiaoLocation";
8
+ import { type SearchToutiaoUserIDParams } from "./actions/searchToutiaoUserID";
6
9
  import { type searchXiaohongshuLocationParams } from "./actions/searchXiaohongshuLocation";
7
10
  import { type SearchXiaohongshuTopicListParams } from "./actions/searchXiaohongshuTopicList";
8
11
  import { type ToutiaoPublishParams } from "./actions/toutiaoPublish";
@@ -23,7 +26,10 @@ export declare class Action {
23
26
  XhsFansExport(params: GetXhsFansSearchParams): Promise<ResponseData<import("./types").Xiaohongshu.FansCount>>;
24
27
  WxFansExport(params: GetWxFansSearchParams): Promise<ResponseData<import("./types").Weixin.FansCount>>;
25
28
  BjhFansExport(params: GetBjhFansSearchParams): Promise<ResponseData<import("./types").BaiJiaHao.FansCount>>;
29
+ searchToutiaoUserID(params: SearchToutiaoUserIDParams): Promise<ResponseData<import("./types").Toutiao.SuggestWords[]>>;
30
+ searchToutiaoLocation(params: SearchToutiaoLocationParams): Promise<ResponseData<import("./types").Toutiao.CityPoi[]>>;
26
31
  getToutiaoConfig(params: GetToutiaoConfigParams): Promise<ResponseData<import("./actions/getToutiaoConfig").GetToutiaoConfigResult>>;
32
+ getBaijiahaoConfig(params: GetBaijiahaoConfigParams): Promise<ResponseData<import("./actions/getBaijiaohaoConfig").ConfigData[]>>;
27
33
  baijiahaoPublish(params: BaijiahaoPublishParams): Promise<ResponseData<string>>;
28
34
  getBaijiahaoActivity(params: GetBaijiahaoActivityParams): Promise<ResponseData<import("./actions/getBaijiahaoActivity").ActivityData[]>>;
29
35
  xiaohongshuPublish(params: XiaohongshuPublishParams): Promise<ResponseData<string>>;
package/dist/index.js CHANGED
@@ -1523,13 +1523,15 @@ var __webpack_exports__ = {};
1523
1523
  is_checked: 1
1524
1524
  }
1525
1525
  ] : [],
1526
- ...isAi ? [
1527
- {
1528
- id: "aigc_bjh_status",
1529
- is_checked: 1
1530
- }
1531
- ] : []
1526
+ ...params.settingInfo.baijiahaoPublishConf?.map((item)=>({
1527
+ id: item.confName,
1528
+ is_checked: item.isChecked ? 1 : 0
1529
+ })) || []
1532
1530
  ];
1531
+ if (isAi && !activity_list.some((item)=>'aigc_bjh_status' in item)) activity_list.push({
1532
+ id: 'aigc_bjh_status',
1533
+ is_checked: 1
1534
+ });
1533
1535
  const publishData = {
1534
1536
  title: params.settingInfo.baijiahaoTitle,
1535
1537
  content,
@@ -1545,6 +1547,7 @@ var __webpack_exports__ = {};
1545
1547
  usingImgFilter: "false",
1546
1548
  source: "upload",
1547
1549
  cover_source: "upload",
1550
+ event2news: params.settingInfo?.baijiahaoEvent2News ? 2 : 0,
1548
1551
  activity_list
1549
1552
  };
1550
1553
  params.settingInfo.timer && (publishData['timer_time'] = params.settingInfo.timer);
@@ -1652,12 +1655,17 @@ var __webpack_exports__ = {};
1652
1655
  await abstractFormItem.click();
1653
1656
  await abstractFormItem.fill(params.settingInfo.baijiahaoAbstract);
1654
1657
  const isAi = params.settingInfo.baijiahaoIsAi.includes("isAi");
1655
- if (isAi) {
1656
- const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
1657
- await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
1658
- hasText: "AI创作声明"
1659
- }).click();
1658
+ const settingFormItem = page.locator(".bjh-edit-wrap-set .cheetah-form-item").nth(5);
1659
+ if (isAi) await settingFormItem.locator("label.cheetah-checkbox-wrapper").filter({
1660
+ hasText: "AI创作声明"
1661
+ }).click();
1662
+ if (params.settingInfo.baijiahaoPublishConf) for (const item of params.settingInfo.baijiahaoPublishConf){
1663
+ const _settingFormItem = settingFormItem.locator("label.cheetah-checkbox-wrapper").locator(`span.${item.confName}`);
1664
+ if (await _settingFormItem.isChecked() !== item.isChecked) await _settingFormItem.click();
1665
+ await page.waitForTimeout(200);
1660
1666
  }
1667
+ const enent2NewsBtn = page.locator("input#event2news");
1668
+ if (await enent2NewsBtn.isVisible() && params.settingInfo.baijiahaoEvent2News) await enent2NewsBtn.click();
1661
1669
  if (params.settingInfo.baijiahaoActivity.length > 0 && params.settingInfo.baijiahaoSelectActivityCache.length > 0) {
1662
1670
  const activity = params.settingInfo.baijiahaoActivity.filter((it)=>params.settingInfo.baijiahaoSelectActivityCache.includes(it.id));
1663
1671
  if (activity.length > 0) {
@@ -1752,6 +1760,7 @@ var __webpack_exports__ = {};
1752
1760
  hasText: /^发布/
1753
1761
  }).locator("button").click();
1754
1762
  });
1763
+ await page.waitForTimeout(200000);
1755
1764
  await page.close();
1756
1765
  return (0, share_namespaceObject.success)(articleId, articleId ? "发布成功" : message);
1757
1766
  };
@@ -1838,6 +1847,28 @@ var __webpack_exports__ = {};
1838
1847
  userRights
1839
1848
  });
1840
1849
  };
1850
+ const getBaijiahaoConfig = async (_task, params)=>{
1851
+ const cookies = params.cookies ?? [];
1852
+ const http = new Http({
1853
+ headers: {
1854
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
1855
+ token: params.token
1856
+ }
1857
+ });
1858
+ const res = await http.api({
1859
+ method: "get",
1860
+ url: "https://baijiahao.baidu.com/pcui/article/edit",
1861
+ params: {
1862
+ type: "news"
1863
+ }
1864
+ });
1865
+ return (0, share_namespaceObject.success)(res?.data?.article.activity_list.map((_item)=>({
1866
+ id: _item.id,
1867
+ name: _item.name,
1868
+ detail: _item.detail,
1869
+ is_enable: _item.is_enable
1870
+ })) ?? [], "获取头条发布配置项成功");
1871
+ };
1841
1872
  const searchToutiaoTopicList = async (_task, params)=>{
1842
1873
  const http = new Http({
1843
1874
  headers: {
@@ -1860,6 +1891,72 @@ var __webpack_exports__ = {};
1860
1891
  return (0, share_namespaceObject.success)([]);
1861
1892
  }
1862
1893
  };
1894
+ const searchToutiaoLocation = async (_task, params)=>{
1895
+ const http = new Http({
1896
+ headers: {
1897
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
1898
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
1899
+ biz: 1231
1900
+ }
1901
+ });
1902
+ try {
1903
+ const res = await http.api({
1904
+ method: "post",
1905
+ url: "https://mp.toutiao.com/poi/api/searchplace",
1906
+ data: {
1907
+ appid: 1231,
1908
+ device: 2,
1909
+ keywords: params.placeName,
1910
+ language: "zh-CN",
1911
+ location: "-1,-1",
1912
+ offset: 20,
1913
+ page: 1,
1914
+ region: "CN",
1915
+ scenario: "TIPS",
1916
+ timestamp: Math.floor(Date.now() / 1000)
1917
+ }
1918
+ });
1919
+ if (200 === res.code) return (0, share_namespaceObject.success)(res.data.poi.map((item)=>({
1920
+ position: item.name,
1921
+ city: item.city,
1922
+ longitude: item.longitude,
1923
+ latitude: item.latitude,
1924
+ type_code: item.type_code,
1925
+ poi_id: item.id
1926
+ })));
1927
+ return (0, share_namespaceObject.success)([]);
1928
+ } catch (error) {
1929
+ return (0, share_namespaceObject.success)([]);
1930
+ }
1931
+ };
1932
+ const searchToutiaoUserInfo = async (_task, params)=>{
1933
+ const http = new Http({
1934
+ headers: {
1935
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
1936
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
1937
+ }
1938
+ });
1939
+ try {
1940
+ const res = await http.api({
1941
+ method: "get",
1942
+ url: "https://mp.toutiao.com/ugc/publish/post/v1/suggest/",
1943
+ params: {
1944
+ words: params.UserName,
1945
+ language: "zh",
1946
+ app_name: "toutiao_mp"
1947
+ }
1948
+ });
1949
+ if (0 === res.err_no) return (0, share_namespaceObject.success)(res.data.suggest.map((item)=>({
1950
+ user_id: item.user.info.user_id,
1951
+ name: item.user.info.name,
1952
+ avatar_url: item.user.info.avatar_url,
1953
+ followers_count: item.user.relation_count.followers_count
1954
+ })), '搜索成功');
1955
+ return (0, share_namespaceObject.success)([]);
1956
+ } catch (error) {
1957
+ return (0, share_namespaceObject.success)([]);
1958
+ }
1959
+ };
1863
1960
  const searchXiaohongshuLocation = async (_task, params)=>{
1864
1961
  const http = new Http({
1865
1962
  headers: {
@@ -1947,7 +2044,7 @@ var __webpack_exports__ = {};
1947
2044
  return error || ("draft" === saveType ? "文章同步异常,请稍后重试。" : "文章发布异常,请稍后重试。");
1948
2045
  };
1949
2046
  const mock_mockAction = async (task, params)=>{
1950
- const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal } = params.settingInfo;
2047
+ const { toutiaoSingleCover, toutiaoMultCover, toutiaoCoverType, toutiaoOriginal, toutiaoExclusive, toutiaoClaim } = params.settingInfo;
1951
2048
  const tmpCachePath = task.getTmpPath();
1952
2049
  const http = new Http({
1953
2050
  headers: {
@@ -2003,23 +2100,27 @@ var __webpack_exports__ = {};
2003
2100
  toutiaoSingleCover
2004
2101
  ] : "multiple" === toutiaoCoverType ? toutiaoMultCover : [];
2005
2102
  const coverRes = await uploadImages(coverUrl);
2006
- const isSingleTitle = "single" === params.settingInfo.toutiaoTitleType;
2007
2103
  const location = params.settingInfo.toutiaoLocation;
2008
2104
  const topics = params.settingInfo.toutiaoTopic || [];
2009
- const multiTitleData = params.settingInfo.subTitles.map((title)=>({
2010
- id: "0",
2011
- visibility_level: 0,
2012
- source: "author",
2013
- old_source: "author",
2014
- text: title,
2015
- version: "author",
2016
- ai_title: ""
2017
- }));
2018
2105
  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("");
2106
+ let sourceData = {
2107
+ source_type: toutiaoClaim ? toutiaoClaim.type : 5
2108
+ };
2109
+ if (toutiaoClaim && 1 === toutiaoClaim.type) {
2110
+ if (!toutiaoClaim?.source_author_uid) return {
2111
+ code: 500,
2112
+ message: "请填写作者ID",
2113
+ data: ""
2114
+ };
2115
+ sourceData = {
2116
+ ...sourceData,
2117
+ source_author_uid: toutiaoClaim.source_author_uid,
2118
+ time_format: toutiaoClaim.time_format,
2119
+ position: toutiaoClaim.position
2120
+ };
2121
+ }
2019
2122
  const extraData = {
2020
2123
  content_word_cnt: params.settingInfo.cntWord,
2021
- is_multi_title: isSingleTitle ? 0 : 1,
2022
- sub_titles: isSingleTitle ? [] : multiTitleData,
2023
2124
  gd_ext: {
2024
2125
  entrance: "",
2025
2126
  from_page: "publisher_mp",
@@ -2028,12 +2129,7 @@ var __webpack_exports__ = {};
2028
2129
  is_message: 0
2029
2130
  },
2030
2131
  tuwen_wtt_trans_flag: "0",
2031
- info_source: {
2032
- source_type: 5,
2033
- source_link: "",
2034
- time_format: "",
2035
- position: {}
2036
- },
2132
+ info_source: sourceData,
2037
2133
  ...location ? {
2038
2134
  city: location.label,
2039
2135
  city_code: location.value
@@ -2080,8 +2176,7 @@ var __webpack_exports__ = {};
2080
2176
  }
2081
2177
  }))),
2082
2178
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
2083
- claim_origin: toutiaoOriginal.includes("original") ? 1 : 0,
2084
- claim_exclusive: toutiaoOriginal.includes("exclusive") ? 1 : 0
2179
+ claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal.includes("exclusive") ? 1 : 0
2085
2180
  };
2086
2181
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
2087
2182
  let publishOption = {};
@@ -2250,11 +2345,38 @@ var __webpack_exports__ = {};
2250
2345
  }).locator("xpath=..");
2251
2346
  const isAdOptionVisible = await adContainer.isVisible();
2252
2347
  if (isAdOptionVisible) await adContainer.locator(`label.byte-radio:has(input[value="${getAddTypeValue(params.settingInfo.toutiaoAd)}"])`).click();
2253
- if (params.settingInfo.toutiaoOriginal.includes("exclusive")) {
2254
- const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
2255
- hasText: "声明首发"
2256
- }).locator("xpath=..");
2257
- exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").click();
2348
+ const exclusiveContainer = page.locator(".form-container .edit-cell .edit-label").filter({
2349
+ hasText: "声明首发"
2350
+ }).locator("xpath=..");
2351
+ if (params.settingInfo.toutiaoOriginal.includes("exclusive") || params.settingInfo.toutiaoExclusive) exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").check();
2352
+ else exclusiveContainer.locator(".exclusive .exclusive-checkbox-wraper .byte-checkbox").uncheck();
2353
+ let claim = params.settingInfo.toutiaoClaim ? params.settingInfo.toutiaoClaim.type : 5;
2354
+ switch(claim){
2355
+ case 3:
2356
+ await page.locator(".source-wrap .byte-checkbox", {
2357
+ hasText: "引用AI"
2358
+ }).locator(".byte-checkbox-mask").check();
2359
+ break;
2360
+ case 4:
2361
+ await page.locator(".source-wrap .byte-checkbox", {
2362
+ hasText: "取材网络"
2363
+ }).locator(".byte-checkbox-mask").check();
2364
+ break;
2365
+ case 5:
2366
+ await page.locator(".source-wrap .byte-checkbox", {
2367
+ hasText: "个人观点,仅供参考"
2368
+ }).locator(".byte-checkbox-mask").check();
2369
+ break;
2370
+ case 6:
2371
+ await page.locator(".source-wrap .byte-checkbox", {
2372
+ hasText: "虚构演绎,故事经历"
2373
+ }).locator(".byte-checkbox-mask").check();
2374
+ break;
2375
+ default:
2376
+ await page.locator(".source-wrap .byte-checkbox", {
2377
+ hasText: "个人观点,仅供参考"
2378
+ }).locator(".byte-checkbox-mask").check();
2379
+ break;
2258
2380
  }
2259
2381
  const articleId = await new Promise(async (resolve)=>{
2260
2382
  const handleResponse = async (response)=>{
@@ -2266,7 +2388,7 @@ var __webpack_exports__ = {};
2266
2388
  }
2267
2389
  };
2268
2390
  page.on("response", handleResponse);
2269
- if (params.settingInfo.timer) {
2391
+ if (params.settingInfo.timer && "publish" == params.saveType) {
2270
2392
  await page.locator(".publish-footer button").filter({
2271
2393
  hasText: "定时发布"
2272
2394
  }).click();
@@ -2312,7 +2434,7 @@ var __webpack_exports__ = {};
2312
2434
  }).click();
2313
2435
  }
2314
2436
  await page.close();
2315
- return (0, share_namespaceObject.success)(articleId);
2437
+ return (0, share_namespaceObject.success)(articleId, "publish" === params.saveType ? "发布成功" : "保存草稿成功");
2316
2438
  };
2317
2439
  const COVER_TYPE = {
2318
2440
  no: 1,
@@ -3098,7 +3220,7 @@ var __webpack_exports__ = {};
3098
3220
  f: "json",
3099
3221
  ajax: 1,
3100
3222
  is_release_publish_page: params.masssend ? 0 : 1,
3101
- send_time: 0,
3223
+ send_time: params.settingInfo.timer ? params.settingInfo.timer : 0,
3102
3224
  random: Math.random().toString()
3103
3225
  })
3104
3226
  });
@@ -3252,6 +3374,9 @@ var __webpack_exports__ = {};
3252
3374
  t: "ajax-response",
3253
3375
  token: params.token,
3254
3376
  lang: "zh_CN",
3377
+ ...params.settingInfo.timer ? {
3378
+ action: "time_send"
3379
+ } : {},
3255
3380
  ...params.masssend ? {} : {
3256
3381
  is_release_publish_page: 1
3257
3382
  }
@@ -4404,7 +4529,7 @@ var __webpack_exports__ = {};
4404
4529
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
4405
4530
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
4406
4531
  };
4407
- var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.1"}');
4532
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.11-beta.2"}');
4408
4533
  class Action {
4409
4534
  constructor(task){
4410
4535
  this.task = task;
@@ -4440,9 +4565,18 @@ var __webpack_exports__ = {};
4440
4565
  BjhFansExport(params) {
4441
4566
  return this.bindTask(BjhFansExport, params);
4442
4567
  }
4568
+ searchToutiaoUserID(params) {
4569
+ return this.bindTask(searchToutiaoUserInfo, params);
4570
+ }
4571
+ searchToutiaoLocation(params) {
4572
+ return this.bindTask(searchToutiaoLocation, params);
4573
+ }
4443
4574
  getToutiaoConfig(params) {
4444
4575
  return this.bindTask(getToutiaoConfig, params);
4445
4576
  }
4577
+ getBaijiahaoConfig(params) {
4578
+ return this.bindTask(getBaijiahaoConfig, params);
4579
+ }
4446
4580
  baijiahaoPublish(params) {
4447
4581
  return this.bindTask(baijiahaoPublish, params);
4448
4582
  }