zalo-agent-cli 1.0.14 → 1.0.15
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/package.json +1 -1
- package/src/commands/msg.js +14 -3
package/package.json
CHANGED
package/src/commands/msg.js
CHANGED
|
@@ -13,16 +13,27 @@ export function registerMsgCommands(program) {
|
|
|
13
13
|
msg.command("send <threadId> <message>")
|
|
14
14
|
.description("Send a text message")
|
|
15
15
|
.option("-t, --type <n>", "Thread type: 0=User, 1=Group", "0")
|
|
16
|
+
.option(
|
|
17
|
+
"--mention <specs...>",
|
|
18
|
+
"Mention users in group message. Format: pos:userId:len (e.g. 0:USER_ID:5). Use userId=-1 for @All.",
|
|
19
|
+
)
|
|
16
20
|
.option(
|
|
17
21
|
"--react <icon>",
|
|
18
22
|
"Auto-react to sent message. Codes: :> (haha), /-heart (heart), /-strong (like), :o (wow), :-(( (cry), :-h (angry)",
|
|
19
23
|
)
|
|
20
24
|
.action(async (threadId, message, opts) => {
|
|
21
25
|
try {
|
|
22
|
-
//
|
|
26
|
+
// Parse mention specs: "pos:uid:len" → { pos, uid, len }
|
|
27
|
+
const mentions = (opts.mention || []).map((spec) => {
|
|
28
|
+
const [pos, uid, len] = spec.split(":");
|
|
29
|
+
return { pos: Number(pos), uid, len: Number(len) };
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Build message content object if mentions exist
|
|
33
|
+
const msgContent = mentions.length > 0 ? { msg: message, mentions } : message;
|
|
34
|
+
|
|
23
35
|
const cliMsgId = String(Date.now());
|
|
24
|
-
const result = await getApi().sendMessage(
|
|
25
|
-
// Include cliMsgId in output for later use with react command
|
|
36
|
+
const result = await getApi().sendMessage(msgContent, threadId, Number(opts.type));
|
|
26
37
|
result.cliMsgId = cliMsgId;
|
|
27
38
|
output(result, program.opts().json, () => success("Message sent"));
|
|
28
39
|
|