@vitex/tcm-cli 0.1.0 → 0.2.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/README.md +3 -1
- package/package.json +1 -1
- package/src/args.js +8 -0
- package/src/commands/comment-strategy.js +65 -0
- package/src/commands/comment.js +30 -3
- package/src/commands/common.js +2 -0
- package/src/commands/index.js +2 -0
- package/src/index.js +8 -2
package/README.md
CHANGED
|
@@ -114,6 +114,7 @@ tcm logout
|
|
|
114
114
|
- `--input @input.json`
|
|
115
115
|
- 文件上传(multipart):传本地路径,如 `--file ./a.png`
|
|
116
116
|
- 布尔筛选:出现即为 `true`,例如 `--verified`
|
|
117
|
+
- 必填布尔值:显式写 `true` / `false`,例如 `tcm comment update --folded false`(`--folded` 这种开关写法表达不了 `false`)
|
|
117
118
|
|
|
118
119
|
## 命令一览
|
|
119
120
|
|
|
@@ -170,8 +171,9 @@ tcm logout
|
|
|
170
171
|
|
|
171
172
|
- `author`:`list`、`get`、`create`、`update`、`status`、`profile`
|
|
172
173
|
- `aweme`:`list`、`get`、`analysis`
|
|
173
|
-
- `comment`:`list`、`get`
|
|
174
|
+
- `comment`:`list`、`get`、`refresh`、`update`
|
|
174
175
|
- `comment-candidate`:`list`、`discard`
|
|
176
|
+
- `comment-strategy`(仅管理员):`list`、`get`、`create`、`update`、`delete`
|
|
175
177
|
- `hot-comment`:`list`
|
|
176
178
|
|
|
177
179
|
### material / draft / item — 素材 / 草稿 / 作品
|
package/package.json
CHANGED
package/src/args.js
CHANGED
|
@@ -53,6 +53,14 @@ function coerce(name, spec, raw) {
|
|
|
53
53
|
}
|
|
54
54
|
case 'boolean':
|
|
55
55
|
return raw === true || raw === 'true'
|
|
56
|
+
case 'flag': {
|
|
57
|
+
// 值必须显式给出:flag 用字符串选项承接,--x false 才能真的传 false。
|
|
58
|
+
const text = String(raw).trim().toLowerCase()
|
|
59
|
+
if (text !== 'true' && text !== 'false') {
|
|
60
|
+
throw new UsageError(`--${name} 需要是 true 或 false`)
|
|
61
|
+
}
|
|
62
|
+
return text === 'true'
|
|
63
|
+
}
|
|
56
64
|
default:
|
|
57
65
|
return String(raw)
|
|
58
66
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { pick, post, string, number, flag, array, json, pageNum, pageSize, id } from './common.js'
|
|
2
|
+
|
|
3
|
+
/** 创建 / 编辑共用的请求体:windows 是 [{begin,end,limit}] 的 JSON 数组,不传的字段按覆盖语义处理。 */
|
|
4
|
+
const strategyBody = (p) =>
|
|
5
|
+
pick(p, ['id', 'name', 'description', 'tags', 'windows', 'interval', 'weight', 'enabled'])
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
summary: '评论策略(仅管理员)',
|
|
9
|
+
commands: {
|
|
10
|
+
list: {
|
|
11
|
+
summary: '分页查询评论策略',
|
|
12
|
+
params: {
|
|
13
|
+
keyword: string('关键词(策略名称)'),
|
|
14
|
+
enabled: flag('只看启用 / 停用:true / false'),
|
|
15
|
+
pageNum: pageNum(1),
|
|
16
|
+
pageSize: pageSize(20),
|
|
17
|
+
},
|
|
18
|
+
build: (p) =>
|
|
19
|
+
post('/api/comment/strategy/page', pick(p, ['keyword', 'enabled', 'pageNum', 'pageSize'])),
|
|
20
|
+
},
|
|
21
|
+
get: {
|
|
22
|
+
summary: '评论策略详情',
|
|
23
|
+
params: { id: id('策略 ID') },
|
|
24
|
+
build: (p) => post('/api/comment/strategy/detail', pick(p, ['id'])),
|
|
25
|
+
},
|
|
26
|
+
create: {
|
|
27
|
+
summary: '创建评论策略',
|
|
28
|
+
params: {
|
|
29
|
+
name: string('策略名称', { required: true }),
|
|
30
|
+
description: string('策略描述'),
|
|
31
|
+
tags: array('命中哪些账号标签,可重复/逗号分隔;不传表示不限账号'),
|
|
32
|
+
windows: json(
|
|
33
|
+
'时间窗口 JSON 数组,如 \'[{"begin":9,"end":12,"limit":5}]\'(小时整点,0≤begin<end≤24,limit 0~30)',
|
|
34
|
+
{ required: true },
|
|
35
|
+
),
|
|
36
|
+
interval: number('评论间隔(分钟,1~240)', { required: true }),
|
|
37
|
+
weight: number('策略权重(0~100,必填;同账号命中多条时取最大)', { required: true }),
|
|
38
|
+
enabled: flag('是否启用,true / false(不传默认启用)'),
|
|
39
|
+
},
|
|
40
|
+
build: (p) => post('/api/comment/strategy/create', strategyBody(p)),
|
|
41
|
+
},
|
|
42
|
+
update: {
|
|
43
|
+
summary: '编辑评论策略(整体覆盖)',
|
|
44
|
+
params: {
|
|
45
|
+
id: id('策略 ID'),
|
|
46
|
+
name: string('策略名称', { required: true }),
|
|
47
|
+
description: string('策略描述'),
|
|
48
|
+
tags: array('命中哪些账号标签,可重复/逗号分隔;不传会清空'),
|
|
49
|
+
windows: json(
|
|
50
|
+
'时间窗口 JSON 数组,如 \'[{"begin":9,"end":12,"limit":5}]\'(小时整点,0≤begin<end≤24,limit 0~30)',
|
|
51
|
+
{ required: true },
|
|
52
|
+
),
|
|
53
|
+
interval: number('评论间隔(分钟,1~240)', { required: true }),
|
|
54
|
+
weight: number('策略权重(0~100)', { required: true }),
|
|
55
|
+
enabled: flag('是否启用,true / false(不传默认启用)'),
|
|
56
|
+
},
|
|
57
|
+
build: (p) => post('/api/comment/strategy/update', strategyBody(p)),
|
|
58
|
+
},
|
|
59
|
+
delete: {
|
|
60
|
+
summary: '删除评论策略',
|
|
61
|
+
params: { id: id('策略 ID') },
|
|
62
|
+
build: (p) => post('/api/comment/strategy/delete', pick(p, ['id'])),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}
|
package/src/commands/comment.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pick, post, string, date, pageNum, pageSize, id } from './common.js'
|
|
1
|
+
import { pick, post, string, date, pageNum, pageSize, id, number, flag } from './common.js'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
summary: '评论',
|
|
@@ -10,8 +10,11 @@ export default {
|
|
|
10
10
|
platformAwemeId: string('平台作品 ID'),
|
|
11
11
|
accountSecUid: string('账号 secUid'),
|
|
12
12
|
keyword: string('关键词'),
|
|
13
|
-
startDate: date('
|
|
14
|
-
endDate: date('
|
|
13
|
+
startDate: date('开始日期(发布时间)'),
|
|
14
|
+
endDate: date('结束日期(发布时间)'),
|
|
15
|
+
refreshStartDate: date('刷新开始日期'),
|
|
16
|
+
refreshEndDate: date('刷新结束日期'),
|
|
17
|
+
minDiggCount: number('最小点赞数'),
|
|
15
18
|
pageNum: pageNum(1),
|
|
16
19
|
pageSize: pageSize(20),
|
|
17
20
|
},
|
|
@@ -25,6 +28,9 @@ export default {
|
|
|
25
28
|
'keyword',
|
|
26
29
|
'startDate',
|
|
27
30
|
'endDate',
|
|
31
|
+
'refreshStartDate',
|
|
32
|
+
'refreshEndDate',
|
|
33
|
+
'minDiggCount',
|
|
28
34
|
'pageNum',
|
|
29
35
|
'pageSize',
|
|
30
36
|
]),
|
|
@@ -35,5 +41,26 @@ export default {
|
|
|
35
41
|
params: { id: id('评论 ID') },
|
|
36
42
|
build: (p) => post('/api/comment/comment/detail', pick(p, ['id'])),
|
|
37
43
|
},
|
|
44
|
+
refresh: {
|
|
45
|
+
summary: '刷新评论(实时拉抖音最新数据,点赞没变大就不改)',
|
|
46
|
+
params: { id: id('评论 ID') },
|
|
47
|
+
build: (p) => post('/api/comment/comment/refresh', pick(p, ['id'])),
|
|
48
|
+
},
|
|
49
|
+
update: {
|
|
50
|
+
summary: '直接更新评论数据(整体覆盖)',
|
|
51
|
+
params: {
|
|
52
|
+
id: id('评论 ID'),
|
|
53
|
+
diggCount: number('点赞数(不能小于当前值)', { required: true }),
|
|
54
|
+
replyCount: number('回复数', { required: true }),
|
|
55
|
+
folded: flag('是否折叠', { required: true }),
|
|
56
|
+
hot: flag('是否热评', { required: true }),
|
|
57
|
+
authorDigged: flag('作者是否点赞', { required: true }),
|
|
58
|
+
},
|
|
59
|
+
build: (p) =>
|
|
60
|
+
post(
|
|
61
|
+
'/api/comment/comment/update',
|
|
62
|
+
pick(p, ['id', 'diggCount', 'replyCount', 'folded', 'hot', 'authorDigged']),
|
|
63
|
+
),
|
|
64
|
+
},
|
|
38
65
|
},
|
|
39
66
|
}
|
package/src/commands/common.js
CHANGED
|
@@ -24,6 +24,8 @@ export const get = (path) => ({ method: 'GET', path })
|
|
|
24
24
|
export const string = (desc, extra = {}) => ({ type: 'string', desc, ...extra })
|
|
25
25
|
export const number = (desc, extra = {}) => ({ type: 'number', desc, ...extra })
|
|
26
26
|
export const boolean = (desc, extra = {}) => ({ type: 'boolean', desc, ...extra })
|
|
27
|
+
/** 必须显式写 true / false 的布尔参数:boolean 选项只能表达「开了」,没法表达 false。 */
|
|
28
|
+
export const flag = (desc, extra = {}) => ({ type: 'flag', desc, ...extra })
|
|
27
29
|
export const array = (desc, extra = {}) => ({ type: 'array', desc, ...extra })
|
|
28
30
|
export const json = (desc, extra = {}) => ({ type: 'json', desc, ...extra })
|
|
29
31
|
|
package/src/commands/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import author from './author.js'
|
|
|
11
11
|
import aweme from './aweme.js'
|
|
12
12
|
import comment from './comment.js'
|
|
13
13
|
import commentCandidate from './comment-candidate.js'
|
|
14
|
+
import commentStrategy from './comment-strategy.js'
|
|
14
15
|
import hotComment from './hot-comment.js'
|
|
15
16
|
import material from './material.js'
|
|
16
17
|
import draft from './draft.js'
|
|
@@ -31,6 +32,7 @@ export const groups = {
|
|
|
31
32
|
aweme,
|
|
32
33
|
comment,
|
|
33
34
|
'comment-candidate': commentCandidate,
|
|
35
|
+
'comment-strategy': commentStrategy,
|
|
34
36
|
'hot-comment': hotComment,
|
|
35
37
|
material,
|
|
36
38
|
draft,
|
package/src/index.js
CHANGED
|
@@ -146,8 +146,14 @@ function handleError(error, compact) {
|
|
|
146
146
|
|
|
147
147
|
function typeLabel(spec) {
|
|
148
148
|
const base =
|
|
149
|
-
{
|
|
150
|
-
|
|
149
|
+
{
|
|
150
|
+
string: 'string',
|
|
151
|
+
number: 'number',
|
|
152
|
+
boolean: 'boolean',
|
|
153
|
+
flag: 'true / false',
|
|
154
|
+
array: 'array',
|
|
155
|
+
json: 'json'
|
|
156
|
+
}[spec.type] || 'string'
|
|
151
157
|
return spec.type === 'array' ? `${base}(可重复/逗号分隔)` : base
|
|
152
158
|
}
|
|
153
159
|
|