lansenger-cli 1.0.0 → 1.0.1
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 +395 -0
- package/dist/commands/calendar.js +153 -67
- package/dist/commands/callback.js +73 -22
- package/dist/commands/chat.js +26 -6
- package/dist/commands/config.js +30 -14
- package/dist/commands/department.js +20 -16
- package/dist/commands/group.js +66 -43
- package/dist/commands/media.js +41 -18
- package/dist/commands/message.js +278 -132
- package/dist/commands/oauth.js +36 -15
- package/dist/commands/staff.js +55 -37
- package/dist/commands/streaming.js +9 -9
- package/dist/commands/todo.js +142 -69
- package/dist/main.js +1 -1
- package/package.json +3 -3
package/dist/commands/message.js
CHANGED
|
@@ -7,24 +7,27 @@ function registerMessageCommands(program) {
|
|
|
7
7
|
cmd
|
|
8
8
|
.command("send-text")
|
|
9
9
|
.description("Send a text message")
|
|
10
|
-
.
|
|
11
|
-
.
|
|
10
|
+
.argument("<chatId>", "Chat ID (user/group)")
|
|
11
|
+
.argument("<content>", "Text content")
|
|
12
|
+
.option("-f, --file <path>", "File path to attach", "")
|
|
13
|
+
.option("-t, --media-type <type>", "1=video, 2=image, 3=file (auto-detected if omitted)")
|
|
14
|
+
.option("--cover-image <path>", "Cover image path for video attachments", "")
|
|
12
15
|
.option("-g, --group", "Send as group message", false)
|
|
13
|
-
.option("--mention-all", "
|
|
14
|
-
.option("--mention <ids
|
|
15
|
-
.option("--user-token <token>", "User token for
|
|
16
|
-
.option("--
|
|
17
|
-
.
|
|
18
|
-
.action(async (opts) => {
|
|
16
|
+
.option("--mention-all", "@all in group", false)
|
|
17
|
+
.option("--mention <ids...>", "User IDs to @mention (space-separated, e.g. --mention id1 id2)")
|
|
18
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
19
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
20
|
+
.action(async (chatId, content, opts) => {
|
|
19
21
|
const client = (0, utils_1.getClient)();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
+
const result = await client.sendText(chatId, content, {
|
|
23
|
+
file_path: opts.file || undefined,
|
|
24
|
+
media_type: opts.mediaType ? parseInt(opts.mediaType) : undefined,
|
|
25
|
+
cover_image_path: opts.coverImage || undefined,
|
|
22
26
|
is_group: opts.group,
|
|
23
27
|
reminder_all: opts.mentionAll,
|
|
24
|
-
reminder_user_ids:
|
|
28
|
+
reminder_user_ids: opts.mention || undefined,
|
|
25
29
|
user_token: opts.userToken || undefined,
|
|
26
|
-
|
|
27
|
-
media_type: opts.mediaType ? parseInt(opts.mediaType) : undefined,
|
|
30
|
+
sender_id: opts.senderId || undefined,
|
|
28
31
|
});
|
|
29
32
|
(0, utils_1.checkError)(result);
|
|
30
33
|
(0, utils_1.outputResult)(result);
|
|
@@ -32,20 +35,21 @@ function registerMessageCommands(program) {
|
|
|
32
35
|
cmd
|
|
33
36
|
.command("send-markdown")
|
|
34
37
|
.description("Send a markdown/formatted text message")
|
|
35
|
-
.
|
|
36
|
-
.
|
|
38
|
+
.argument("<chatId>", "Chat ID")
|
|
39
|
+
.argument("<content>", "Markdown content")
|
|
40
|
+
.option("--mention-all", "@all in group", false)
|
|
41
|
+
.option("--mention <ids...>", "User IDs to @mention (space-separated, e.g. --mention id1 id2)")
|
|
37
42
|
.option("-g, --group", "Send as group message", false)
|
|
38
|
-
.option("--
|
|
39
|
-
.option("--
|
|
40
|
-
.
|
|
41
|
-
.action(async (opts) => {
|
|
43
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
44
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
45
|
+
.action(async (chatId, content, opts) => {
|
|
42
46
|
const client = (0, utils_1.getClient)();
|
|
43
|
-
const
|
|
44
|
-
const result = await client.sendMarkdown(opts.chatId, opts.content, {
|
|
45
|
-
is_group: opts.group,
|
|
47
|
+
const result = await client.sendMarkdown(chatId, content, {
|
|
46
48
|
reminder_all: opts.mentionAll,
|
|
47
|
-
reminder_user_ids:
|
|
49
|
+
reminder_user_ids: opts.mention || undefined,
|
|
50
|
+
is_group: opts.group,
|
|
48
51
|
user_token: opts.userToken || undefined,
|
|
52
|
+
sender_id: opts.senderId || undefined,
|
|
49
53
|
});
|
|
50
54
|
(0, utils_1.checkError)(result);
|
|
51
55
|
(0, utils_1.outputResult)(result);
|
|
@@ -53,104 +57,147 @@ function registerMessageCommands(program) {
|
|
|
53
57
|
cmd
|
|
54
58
|
.command("send-file")
|
|
55
59
|
.description("Send a file message")
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
.option("--
|
|
59
|
-
.option("--media-type <type>", "
|
|
60
|
+
.argument("<chatId>", "Chat ID")
|
|
61
|
+
.argument("<filePath>", "Local file path")
|
|
62
|
+
.option("-c, --content <content>", "Content/caption text", "")
|
|
63
|
+
.option("--media-type <type>", "1=video, 2=image, 3=file")
|
|
64
|
+
.option("--cover-image <path>", "Cover image path for video attachments", "")
|
|
60
65
|
.option("-g, --group", "Send as group message", false)
|
|
61
|
-
.option("--user-token <token>", "User token for
|
|
62
|
-
.
|
|
66
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
67
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
68
|
+
.action(async (chatId, filePath, opts) => {
|
|
63
69
|
const client = (0, utils_1.getClient)();
|
|
64
|
-
const result = await client.sendFile(
|
|
65
|
-
caption: opts.
|
|
70
|
+
const result = await client.sendFile(chatId, filePath, {
|
|
71
|
+
caption: opts.content || undefined,
|
|
66
72
|
media_type: opts.mediaType ? parseInt(opts.mediaType) : undefined,
|
|
73
|
+
cover_image_path: opts.coverImage || undefined,
|
|
67
74
|
is_group: opts.group,
|
|
68
75
|
user_token: opts.userToken || undefined,
|
|
76
|
+
sender_id: opts.senderId || undefined,
|
|
69
77
|
});
|
|
70
78
|
(0, utils_1.checkError)(result);
|
|
71
79
|
(0, utils_1.outputResult)(result);
|
|
72
80
|
});
|
|
73
81
|
cmd
|
|
74
|
-
.command("send-
|
|
75
|
-
.description("Send
|
|
76
|
-
.
|
|
77
|
-
.
|
|
78
|
-
.
|
|
79
|
-
.option("--description <desc>", "Card description")
|
|
82
|
+
.command("send-image-url")
|
|
83
|
+
.description("Send an image by URL")
|
|
84
|
+
.argument("<chatId>", "Chat ID")
|
|
85
|
+
.argument("<imageUrl>", "Image URL to send")
|
|
86
|
+
.option("-c, --content <content>", "Content/caption text", "")
|
|
80
87
|
.option("-g, --group", "Send as group message", false)
|
|
81
|
-
.option("--user-token <token>", "User token for
|
|
82
|
-
.
|
|
88
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
89
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
90
|
+
.action(async (chatId, imageUrl, opts) => {
|
|
83
91
|
const client = (0, utils_1.getClient)();
|
|
84
|
-
const result = await client.
|
|
85
|
-
|
|
92
|
+
const result = await client.sendImageUrl(chatId, imageUrl, {
|
|
93
|
+
caption: opts.content || undefined,
|
|
86
94
|
is_group: opts.group,
|
|
87
95
|
user_token: opts.userToken || undefined,
|
|
96
|
+
sender_id: opts.senderId || undefined,
|
|
88
97
|
});
|
|
89
98
|
(0, utils_1.checkError)(result);
|
|
90
99
|
(0, utils_1.outputResult)(result);
|
|
91
100
|
});
|
|
92
101
|
cmd
|
|
93
|
-
.command("send-
|
|
94
|
-
.description("Send
|
|
95
|
-
.
|
|
96
|
-
.
|
|
102
|
+
.command("send-link-card")
|
|
103
|
+
.description("Send a link card message")
|
|
104
|
+
.argument("<chatId>", "Chat ID")
|
|
105
|
+
.argument("<title>", "Card title")
|
|
106
|
+
.argument("<link>", "Card link URL")
|
|
107
|
+
.option("-d, --desc <desc>", "Card description", "")
|
|
108
|
+
.option("--icon <url>", "Icon URL", "")
|
|
109
|
+
.option("--pc-link <url>", "PC link URL", "")
|
|
110
|
+
.option("--pad-link <url>", "Pad link URL", "")
|
|
111
|
+
.option("--from-name <name>", "Source name", "")
|
|
112
|
+
.option("--from-icon <url>", "Source icon URL", "")
|
|
97
113
|
.option("-g, --group", "Send as group message", false)
|
|
98
|
-
.option("--user-token <token>", "User token for
|
|
99
|
-
.
|
|
114
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
115
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
116
|
+
.action(async (chatId, title, link, opts) => {
|
|
100
117
|
const client = (0, utils_1.getClient)();
|
|
101
|
-
const
|
|
102
|
-
|
|
118
|
+
const result = await client.sendLinkCard(chatId, title, link, {
|
|
119
|
+
description: opts.desc || undefined,
|
|
120
|
+
icon_link: opts.icon || undefined,
|
|
121
|
+
pc_link: opts.pcLink || undefined,
|
|
122
|
+
pad_link: opts.padLink || undefined,
|
|
123
|
+
from_name: opts.fromName || undefined,
|
|
124
|
+
from_icon_link: opts.fromIcon || undefined,
|
|
103
125
|
is_group: opts.group,
|
|
104
126
|
user_token: opts.userToken || undefined,
|
|
127
|
+
sender_id: opts.senderId || undefined,
|
|
105
128
|
});
|
|
106
129
|
(0, utils_1.checkError)(result);
|
|
107
130
|
(0, utils_1.outputResult)(result);
|
|
108
131
|
});
|
|
109
132
|
cmd
|
|
110
|
-
.command("send-app-
|
|
111
|
-
.description("Send
|
|
112
|
-
.
|
|
113
|
-
.
|
|
114
|
-
.option("--head-title <title>", "Card head title")
|
|
115
|
-
.option("--body-content <content>", "Card body content")
|
|
116
|
-
.option("--is-dynamic", "Mark as dynamic card", false)
|
|
117
|
-
.option("--fields <json>", "Card fields JSON array")
|
|
118
|
-
.option("--links <json>", "Card links JSON array")
|
|
133
|
+
.command("send-app-articles")
|
|
134
|
+
.description("Send app articles message")
|
|
135
|
+
.argument("<chatId>", "Chat ID")
|
|
136
|
+
.argument("<articles...>", "Articles as JSON dicts, e.g. '{\"title\":\"T\",\"url\":\"U\"}'")
|
|
119
137
|
.option("-g, --group", "Send as group message", false)
|
|
120
|
-
.option("--user-token <token>", "User token for
|
|
121
|
-
.
|
|
138
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
139
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
140
|
+
.action(async (chatId, articles, opts) => {
|
|
122
141
|
const client = (0, utils_1.getClient)();
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const result = await client.sendAppCard(opts.chatId, opts.bodyTitle, {
|
|
126
|
-
head_title: opts.headTitle || undefined,
|
|
127
|
-
body_content: opts.bodyContent || undefined,
|
|
128
|
-
is_dynamic: opts.isDynamic,
|
|
129
|
-
fields,
|
|
130
|
-
links,
|
|
142
|
+
const parsed = articles.map((a) => (0, utils_1.parseJsonOption)(a));
|
|
143
|
+
const result = await client.sendAppArticles(chatId, parsed, {
|
|
131
144
|
is_group: opts.group,
|
|
132
145
|
user_token: opts.userToken || undefined,
|
|
146
|
+
sender_id: opts.senderId || undefined,
|
|
133
147
|
});
|
|
134
148
|
(0, utils_1.checkError)(result);
|
|
135
149
|
(0, utils_1.outputResult)(result);
|
|
136
150
|
});
|
|
137
151
|
cmd
|
|
138
|
-
.command("send-
|
|
139
|
-
.description("Send an
|
|
140
|
-
.
|
|
141
|
-
.
|
|
142
|
-
.option("--
|
|
143
|
-
.option("--
|
|
152
|
+
.command("send-app-card")
|
|
153
|
+
.description("Send an app card message")
|
|
154
|
+
.argument("<chatId>", "Chat ID")
|
|
155
|
+
.argument("<bodyTitle>", "Card body title")
|
|
156
|
+
.option("--head-title <title>", "Card head title", "")
|
|
157
|
+
.option("--sub-title <sub>", "Card sub title", "")
|
|
158
|
+
.option("--content <content>", "Card body content (supports div-style HTML)", "")
|
|
159
|
+
.option("--signature <sig>", "Card signature", "")
|
|
160
|
+
.option("--card-link <url>", "Card link URL", "")
|
|
161
|
+
.option("--pc-card-link <url>", "PC card link URL", "")
|
|
162
|
+
.option("--pad-card-link <url>", "Pad card link URL", "")
|
|
163
|
+
.option("--dynamic", "Enable dynamic card updates", false)
|
|
164
|
+
.option("--staff-id <id>", "Staff ID", "")
|
|
165
|
+
.option("--head-icon <url>", "Head icon URL", "")
|
|
166
|
+
.option("--status-desc <desc>", "Head status description (div-style HTML, max 30 bytes)", "")
|
|
167
|
+
.option("--status-colour <colour>", "Head status DOT colour (hex, e.g. #FFB116)", "")
|
|
168
|
+
.option("--field <json...>", "Card field as JSON, space-separated, e.g. --field '{\"key\":\"k\",\"value\":\"v\"}' '{\"key\":\"k2\",\"value\":\"v2\"}'")
|
|
169
|
+
.option("--link <json...>", "Card link as JSON, space-separated, e.g. --link '{\"title\":\"T\",\"url\":\"U\"}' '{\"title\":\"T2\",\"url\":\"U2\"}'")
|
|
144
170
|
.option("-g, --group", "Send as group message", false)
|
|
145
|
-
.option("--user-token <token>", "User token for
|
|
146
|
-
.
|
|
171
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
172
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
173
|
+
.action(async (chatId, bodyTitle, opts) => {
|
|
147
174
|
const client = (0, utils_1.getClient)();
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
175
|
+
let headStatusInfo = undefined;
|
|
176
|
+
if (opts.statusDesc || opts.statusColour) {
|
|
177
|
+
headStatusInfo = {
|
|
178
|
+
description: opts.statusDesc || "",
|
|
179
|
+
colour: opts.statusColour || "",
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const parsedFields = opts.field ? opts.field.map((f) => (0, utils_1.parseJsonOption)(f)) : undefined;
|
|
183
|
+
const parsedLinks = opts.link ? opts.link.map((l) => (0, utils_1.parseJsonOption)(l)) : undefined;
|
|
184
|
+
const result = await client.sendAppCard(chatId, bodyTitle, {
|
|
185
|
+
head_title: opts.headTitle || undefined,
|
|
186
|
+
body_sub_title: opts.subTitle || undefined,
|
|
187
|
+
body_content: opts.content || undefined,
|
|
188
|
+
signature: opts.signature || undefined,
|
|
189
|
+
card_link: opts.cardLink || undefined,
|
|
190
|
+
pc_card_link: opts.pcCardLink || undefined,
|
|
191
|
+
pad_card_link: opts.padCardLink || undefined,
|
|
192
|
+
is_dynamic: opts.dynamic,
|
|
193
|
+
staff_id: opts.staffId || undefined,
|
|
194
|
+
head_icon_url: opts.headIcon || undefined,
|
|
195
|
+
head_status_info: headStatusInfo,
|
|
196
|
+
fields: parsedFields,
|
|
197
|
+
links: parsedLinks,
|
|
152
198
|
is_group: opts.group,
|
|
153
199
|
user_token: opts.userToken || undefined,
|
|
200
|
+
sender_id: opts.senderId || undefined,
|
|
154
201
|
});
|
|
155
202
|
(0, utils_1.checkError)(result);
|
|
156
203
|
(0, utils_1.outputResult)(result);
|
|
@@ -158,18 +205,25 @@ function registerMessageCommands(program) {
|
|
|
158
205
|
cmd
|
|
159
206
|
.command("update-dynamic-card")
|
|
160
207
|
.description("Update a dynamic card message")
|
|
161
|
-
.
|
|
162
|
-
.option("--
|
|
163
|
-
.option("--
|
|
164
|
-
.option("--
|
|
165
|
-
.
|
|
208
|
+
.argument("<msgId>", "Message ID of the dynamic card")
|
|
209
|
+
.option("--last", "Mark as last update", false)
|
|
210
|
+
.option("--status-desc <desc>", "New status description (div-style HTML, max 30 bytes)", "")
|
|
211
|
+
.option("--status-colour <colour>", "New status DOT colour (hex)", "")
|
|
212
|
+
.option("--link <json...>", "Updated link as JSON, space-separated")
|
|
213
|
+
.action(async (msgId, opts) => {
|
|
166
214
|
const client = (0, utils_1.getClient)();
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
215
|
+
let headStatusInfo = undefined;
|
|
216
|
+
if (opts.statusDesc || opts.statusColour) {
|
|
217
|
+
headStatusInfo = {
|
|
218
|
+
description: opts.statusDesc || "",
|
|
219
|
+
colour: opts.statusColour || "",
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const parsedLinks = opts.link ? opts.link.map((l) => (0, utils_1.parseJsonOption)(l)) : undefined;
|
|
223
|
+
const result = await client.updateDynamicCard(msgId, {
|
|
224
|
+
is_last_update: opts.last,
|
|
171
225
|
head_status_info: headStatusInfo,
|
|
172
|
-
links,
|
|
226
|
+
links: parsedLinks,
|
|
173
227
|
});
|
|
174
228
|
(0, utils_1.checkError)(result);
|
|
175
229
|
(0, utils_1.outputResult)(result);
|
|
@@ -177,78 +231,170 @@ function registerMessageCommands(program) {
|
|
|
177
231
|
cmd
|
|
178
232
|
.command("revoke")
|
|
179
233
|
.description("Revoke messages by IDs")
|
|
180
|
-
.
|
|
181
|
-
.
|
|
234
|
+
.argument("<messageIds...>", "Message IDs to revoke")
|
|
235
|
+
.option("--chat-type <type>", "staff, group, notification, account, or bot", "bot")
|
|
236
|
+
.option("--sender-id <senderId>", "Sender staff ID (required for staff/group)", "")
|
|
237
|
+
.action(async (messageIds, opts) => {
|
|
182
238
|
const client = (0, utils_1.getClient)();
|
|
183
|
-
const
|
|
184
|
-
|
|
239
|
+
const result = await client.revokeMessage(messageIds, {
|
|
240
|
+
chat_type: opts.chatType,
|
|
241
|
+
sender_id: opts.senderId || undefined,
|
|
242
|
+
});
|
|
185
243
|
(0, utils_1.checkError)(result);
|
|
186
244
|
(0, utils_1.outputResult)(result);
|
|
187
245
|
});
|
|
188
246
|
cmd
|
|
189
|
-
.command("send-
|
|
190
|
-
.description("Send a
|
|
191
|
-
.
|
|
192
|
-
.
|
|
193
|
-
.
|
|
194
|
-
.option("--dept
|
|
195
|
-
.option("--
|
|
196
|
-
.option("--
|
|
197
|
-
.
|
|
247
|
+
.command("send-bot-message")
|
|
248
|
+
.description("Send a bot notification message")
|
|
249
|
+
.argument("<msgType>", "Message type")
|
|
250
|
+
.argument("<msgData>", "Message data as JSON")
|
|
251
|
+
.option("--chat-id <ids...>", "Chat IDs, space-separated (or group IDs if --group)")
|
|
252
|
+
.option("--dept <ids...>", "Department IDs, space-separated (bot channel only)")
|
|
253
|
+
.option("--user-token <token>", "User token", "")
|
|
254
|
+
.option("--entry-id <entryId>", "App entry selector", "")
|
|
255
|
+
.option("-g, --group", "Send to groups instead of users", false)
|
|
256
|
+
.action(async (msgType, msgData, opts) => {
|
|
198
257
|
const client = (0, utils_1.getClient)();
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
const deptIds = opts.deptIds ? (0, utils_1.commaList)(opts.deptIds) : undefined;
|
|
202
|
-
const result = await client.sendAccountMessage(opts.msgType, msgData, chatIds, deptIds, {
|
|
203
|
-
account_id: opts.accountId || undefined,
|
|
258
|
+
const parsedData = (0, utils_1.parseJsonOption)(msgData);
|
|
259
|
+
const result = await client.sendBotMessage(msgType, parsedData, opts.chatId || undefined, opts.dept || undefined, {
|
|
204
260
|
user_token: opts.userToken || undefined,
|
|
261
|
+
entry_id: opts.entryId || undefined,
|
|
262
|
+
is_group: opts.group,
|
|
205
263
|
});
|
|
206
264
|
(0, utils_1.checkError)(result);
|
|
207
265
|
(0, utils_1.outputResult)(result);
|
|
208
266
|
});
|
|
209
267
|
cmd
|
|
210
|
-
.command("send-
|
|
211
|
-
.description("Send a
|
|
212
|
-
.
|
|
213
|
-
.
|
|
214
|
-
.
|
|
215
|
-
.option("--user-token <token>", "User token")
|
|
216
|
-
.
|
|
268
|
+
.command("send-group-message")
|
|
269
|
+
.description("Send a group message")
|
|
270
|
+
.argument("<groupId>", "Group ID")
|
|
271
|
+
.argument("<msgType>", "Message type")
|
|
272
|
+
.argument("<msgData>", "Message data as JSON")
|
|
273
|
+
.option("--user-token <token>", "User token", "")
|
|
274
|
+
.option("--sender-id <senderId>", "Sender staff ID", "")
|
|
275
|
+
.option("--mention-all", "@all (text/formatText only)", false)
|
|
276
|
+
.option("--mention <ids...>", "User IDs to @mention, space-separated (text/formatText only)")
|
|
277
|
+
.option("--outlines <outlines>", "Group notification digest", "")
|
|
278
|
+
.option("--entry-id <entryId>", "App entry selector", "")
|
|
279
|
+
.action(async (groupId, msgType, msgData, opts) => {
|
|
217
280
|
const client = (0, utils_1.getClient)();
|
|
218
|
-
const
|
|
219
|
-
const result = await client.
|
|
281
|
+
const parsedData = (0, utils_1.parseJsonOption)(msgData);
|
|
282
|
+
const result = await client.sendGroupMessage(groupId, msgType, parsedData, {
|
|
220
283
|
user_token: opts.userToken || undefined,
|
|
284
|
+
sender_id: opts.senderId || undefined,
|
|
285
|
+
reminder_all: opts.mentionAll,
|
|
286
|
+
reminder_user_ids: opts.mention || undefined,
|
|
287
|
+
outlines: opts.outlines || undefined,
|
|
288
|
+
entry_id: opts.entryId || undefined,
|
|
221
289
|
});
|
|
222
290
|
(0, utils_1.checkError)(result);
|
|
223
291
|
(0, utils_1.outputResult)(result);
|
|
224
292
|
});
|
|
225
293
|
cmd
|
|
226
|
-
.command("
|
|
227
|
-
.description("
|
|
228
|
-
.
|
|
229
|
-
.
|
|
230
|
-
.requiredOption("--msg-data <json>", "Message data JSON")
|
|
231
|
-
.option("--user-token <token>", "User token")
|
|
294
|
+
.command("query-groups")
|
|
295
|
+
.description("Query group IDs with pagination")
|
|
296
|
+
.option("-p, --page <page>", "Page offset", "1")
|
|
297
|
+
.option("-s, --size <size>", "Page size", "100")
|
|
232
298
|
.action(async (opts) => {
|
|
233
299
|
const client = (0, utils_1.getClient)();
|
|
234
|
-
const
|
|
235
|
-
|
|
300
|
+
const result = await client.queryGroups({
|
|
301
|
+
page_offset: parseInt(opts.page),
|
|
302
|
+
page_size: parseInt(opts.size),
|
|
303
|
+
});
|
|
304
|
+
(0, utils_1.checkError)(result);
|
|
305
|
+
(0, utils_1.outputResult)(result);
|
|
306
|
+
});
|
|
307
|
+
cmd
|
|
308
|
+
.command("send-oacard")
|
|
309
|
+
.description("Send an OA card message")
|
|
310
|
+
.argument("<chatId>", "Chat ID")
|
|
311
|
+
.argument("<title>", "OA card title")
|
|
312
|
+
.option("--head <head>", "OA card head title", "")
|
|
313
|
+
.option("--sub-title <sub>", "OA card sub title", "")
|
|
314
|
+
.option("--staff-id <id>", "Staff ID", "")
|
|
315
|
+
.option("--field <json...>", "Card field as JSON, space-separated, e.g. --field '{\"key\":\"k\",\"value\":\"v\"}'")
|
|
316
|
+
.option("--link <url>", "Card click link URL", "")
|
|
317
|
+
.option("--pc-link <url>", "PC link URL", "")
|
|
318
|
+
.option("--pad-link <url>", "Pad link URL", "")
|
|
319
|
+
.option("--card-action <json>", "Card action as JSON dict")
|
|
320
|
+
.option("-g, --group", "Send as group message", false)
|
|
321
|
+
.option("--user-token <token>", "User token for private channel", "")
|
|
322
|
+
.option("--sender-id <senderId>", "Sender staff ID for group message", "")
|
|
323
|
+
.action(async (chatId, title, opts) => {
|
|
324
|
+
const client = (0, utils_1.getClient)();
|
|
325
|
+
const parsedFields = opts.field ? opts.field.map((f) => (0, utils_1.parseJsonOption)(f)) : undefined;
|
|
326
|
+
const parsedAction = opts.cardAction ? (0, utils_1.parseJsonOption)(opts.cardAction) : undefined;
|
|
327
|
+
const result = await client.sendOacard(chatId, title, {
|
|
328
|
+
head: opts.head || undefined,
|
|
329
|
+
sub_title: opts.subTitle || undefined,
|
|
330
|
+
staff_id: opts.staffId || undefined,
|
|
331
|
+
fields: parsedFields,
|
|
332
|
+
link: opts.link || undefined,
|
|
333
|
+
pc_link: opts.pcLink || undefined,
|
|
334
|
+
pad_link: opts.padLink || undefined,
|
|
335
|
+
card_action: parsedAction,
|
|
336
|
+
is_group: opts.group,
|
|
337
|
+
user_token: opts.userToken || undefined,
|
|
338
|
+
sender_id: opts.senderId || undefined,
|
|
339
|
+
});
|
|
340
|
+
(0, utils_1.checkError)(result);
|
|
341
|
+
(0, utils_1.outputResult)(result);
|
|
342
|
+
});
|
|
343
|
+
cmd
|
|
344
|
+
.command("send-account-message")
|
|
345
|
+
.description("Send a public account message")
|
|
346
|
+
.argument("<msgType>", "Message type")
|
|
347
|
+
.argument("<msgData>", "Message data as JSON")
|
|
348
|
+
.option("--chat-id <ids...>", "Chat IDs, space-separated")
|
|
349
|
+
.option("--dept <ids...>", "Department IDs, space-separated")
|
|
350
|
+
.option("--account-id <id>", "Account ID", "")
|
|
351
|
+
.option("--entry-id <entryId>", "App entry selector", "")
|
|
352
|
+
.option("--attach <attach>", "Attach info", "")
|
|
353
|
+
.option("--user-token <token>", "User token", "")
|
|
354
|
+
.action(async (msgType, msgData, opts) => {
|
|
355
|
+
const client = (0, utils_1.getClient)();
|
|
356
|
+
const parsedData = (0, utils_1.parseJsonOption)(msgData);
|
|
357
|
+
const result = await client.sendAccountMessage(msgType, parsedData, opts.chatId || undefined, opts.dept || undefined, {
|
|
358
|
+
account_id: opts.accountId || undefined,
|
|
359
|
+
entry_id: opts.entryId || undefined,
|
|
360
|
+
attach: opts.attach || undefined,
|
|
236
361
|
user_token: opts.userToken || undefined,
|
|
237
362
|
});
|
|
238
363
|
(0, utils_1.checkError)(result);
|
|
239
364
|
(0, utils_1.outputResult)(result);
|
|
240
365
|
});
|
|
366
|
+
cmd
|
|
367
|
+
.command("send-user-message")
|
|
368
|
+
.description("Send a user-to-user private message")
|
|
369
|
+
.argument("<receiverId>", "Receiver user ID")
|
|
370
|
+
.argument("<msgType>", "Message type")
|
|
371
|
+
.argument("<msgData>", "Message data as JSON")
|
|
372
|
+
.option("--user-token <token>", "User token", "")
|
|
373
|
+
.option("--common <json>", "Common data as JSON dict")
|
|
374
|
+
.option("--uuid <uuid>", "Deduplication UUID", "")
|
|
375
|
+
.action(async (receiverId, msgType, msgData, opts) => {
|
|
376
|
+
const client = (0, utils_1.getClient)();
|
|
377
|
+
const parsedData = (0, utils_1.parseJsonOption)(msgData);
|
|
378
|
+
const parsedCommon = opts.common ? (0, utils_1.parseJsonOption)(opts.common) : undefined;
|
|
379
|
+
const result = await client.sendUserMessage(receiverId, msgType, parsedData, {
|
|
380
|
+
user_token: opts.userToken || undefined,
|
|
381
|
+
common: parsedCommon,
|
|
382
|
+
uuid: opts.uuid || undefined,
|
|
383
|
+
});
|
|
384
|
+
(0, utils_1.checkError)(result);
|
|
385
|
+
(0, utils_1.outputResult)(result);
|
|
386
|
+
});
|
|
241
387
|
cmd
|
|
242
388
|
.command("send-reminder")
|
|
243
389
|
.description("Send a reminder for a message")
|
|
244
|
-
.
|
|
245
|
-
.
|
|
246
|
-
.
|
|
247
|
-
.action(async (opts) => {
|
|
390
|
+
.argument("<msgId>", "Message ID to remind about")
|
|
391
|
+
.option("-t, --type <types...>", "Reminder types, space-separated: 1=popup, 2=SMS, 3=phone call")
|
|
392
|
+
.option("-u, --user <ids...>", "User IDs to remind, space-separated (staff openIds)")
|
|
393
|
+
.action(async (msgId, opts) => {
|
|
248
394
|
const client = (0, utils_1.getClient)();
|
|
249
|
-
const reminderTypes =
|
|
250
|
-
const userIdList =
|
|
251
|
-
const result = await client.sendReminderMsg(
|
|
395
|
+
const reminderTypes = opts.type ? opts.type.map(Number) : [];
|
|
396
|
+
const userIdList = opts.user || [];
|
|
397
|
+
const result = await client.sendReminderMsg(msgId, reminderTypes, userIdList);
|
|
252
398
|
(0, utils_1.checkError)(result);
|
|
253
399
|
(0, utils_1.outputResult)(result);
|
|
254
400
|
});
|
package/dist/commands/oauth.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerOauthCommands = registerOauthCommands;
|
|
4
|
+
const lansenger_sdk_ts_1 = require("lansenger-sdk-ts");
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
6
|
function registerOauthCommands(program) {
|
|
6
7
|
const cmd = program.command("oauth").description("OAuth2 user authorization operations");
|
|
7
8
|
cmd
|
|
8
9
|
.command("authorize-url")
|
|
9
10
|
.description("Build an OAuth2 authorize URL")
|
|
10
|
-
.
|
|
11
|
-
.option("--scope <scope>", "OAuth2 scope")
|
|
12
|
-
.option("--state <state>", "State parameter for CSRF protection")
|
|
13
|
-
.action(async (opts) => {
|
|
11
|
+
.argument("<redirectUri>", "Redirect URI after auth")
|
|
12
|
+
.option("-s, --scope <scope>", "OAuth2 scope", "basic_userinfor")
|
|
13
|
+
.option("--state <state>", "State parameter for CSRF protection", "")
|
|
14
|
+
.action(async (redirectUri, opts) => {
|
|
14
15
|
const client = (0, utils_1.getClient)();
|
|
15
|
-
const url = client.buildAuthorizeUrl(
|
|
16
|
+
const url = client.buildAuthorizeUrl(redirectUri, {
|
|
16
17
|
scope: opts.scope || undefined,
|
|
17
18
|
state: opts.state || undefined,
|
|
18
19
|
});
|
|
@@ -21,11 +22,11 @@ function registerOauthCommands(program) {
|
|
|
21
22
|
cmd
|
|
22
23
|
.command("exchange-code")
|
|
23
24
|
.description("Exchange an authorization code for a user token")
|
|
24
|
-
.
|
|
25
|
-
.option("--redirect-uri <uri>", "Redirect URI
|
|
26
|
-
.action(async (opts) => {
|
|
25
|
+
.argument("<code>", "Authorization code from callback")
|
|
26
|
+
.option("--redirect-uri <uri>", "Redirect URI used in authorize", "")
|
|
27
|
+
.action(async (code, opts) => {
|
|
27
28
|
const client = (0, utils_1.getClient)();
|
|
28
|
-
const result = await client.exchangeCode(
|
|
29
|
+
const result = await client.exchangeCode(code, {
|
|
29
30
|
redirect_uri: opts.redirectUri || undefined,
|
|
30
31
|
});
|
|
31
32
|
(0, utils_1.checkError)(result);
|
|
@@ -38,10 +39,13 @@ function registerOauthCommands(program) {
|
|
|
38
39
|
cmd
|
|
39
40
|
.command("refresh-token")
|
|
40
41
|
.description("Refresh a user token")
|
|
41
|
-
.
|
|
42
|
-
.
|
|
42
|
+
.argument("<refreshToken>", "Refresh token")
|
|
43
|
+
.option("-s, --scope <scope>", "Scope", "")
|
|
44
|
+
.action(async (refreshToken, opts) => {
|
|
43
45
|
const client = (0, utils_1.getClient)();
|
|
44
|
-
const result = await client.refreshUserToken(
|
|
46
|
+
const result = await client.refreshUserToken(refreshToken, {
|
|
47
|
+
scope: opts.scope || undefined,
|
|
48
|
+
});
|
|
45
49
|
(0, utils_1.checkError)(result);
|
|
46
50
|
if (result.success && result.user_token) {
|
|
47
51
|
const store = (0, utils_1.getStore)();
|
|
@@ -52,11 +56,28 @@ function registerOauthCommands(program) {
|
|
|
52
56
|
cmd
|
|
53
57
|
.command("user-info")
|
|
54
58
|
.description("Fetch user info using a user token")
|
|
55
|
-
.
|
|
56
|
-
.action(async (
|
|
59
|
+
.argument("<userToken>", "User token")
|
|
60
|
+
.action(async (userToken) => {
|
|
57
61
|
const client = (0, utils_1.getClient)();
|
|
58
|
-
const result = await client.fetchUserInfoByToken(
|
|
62
|
+
const result = await client.fetchUserInfoByToken(userToken);
|
|
59
63
|
(0, utils_1.checkError)(result);
|
|
60
64
|
(0, utils_1.outputResult)(result);
|
|
61
65
|
});
|
|
66
|
+
cmd
|
|
67
|
+
.command("parse-callback")
|
|
68
|
+
.description("Parse the query string from an OAuth2 callback URL")
|
|
69
|
+
.argument("<queryString>", "Query string from callback URL")
|
|
70
|
+
.action(async (queryString) => {
|
|
71
|
+
const params = lansenger_sdk_ts_1.LansengerClient.parseAuthorizeCallback(queryString);
|
|
72
|
+
(0, utils_1.outputResult)(params);
|
|
73
|
+
});
|
|
74
|
+
cmd
|
|
75
|
+
.command("validate-state")
|
|
76
|
+
.description("Validate the state parameter from an OAuth2 callback")
|
|
77
|
+
.argument("<callbackState>", "State from callback")
|
|
78
|
+
.argument("<expectedState>", "Expected state you set")
|
|
79
|
+
.action(async (callbackState, expectedState) => {
|
|
80
|
+
const valid = lansenger_sdk_ts_1.LansengerClient.validateCallbackState(callbackState, expectedState);
|
|
81
|
+
(0, utils_1.outputResult)({ valid });
|
|
82
|
+
});
|
|
62
83
|
}
|