zalo-agent-cli 1.0.14 → 1.0.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zalo-agent-cli",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "CLI tool for Zalo automation — multi-account, proxy support, bank transfers, QR payments",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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
- // Capture clientId before send zca-js uses Date.now() internally
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(message, threadId, Number(opts.type));
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
 
@@ -239,6 +250,24 @@ export function registerMsgCommands(program) {
239
250
  }
240
251
  });
241
252
 
253
+ msg.command("undo <msgId> <threadId>")
254
+ .description("Recall/undo a message for both sides (like Zalo app recall). Requires cliMsgId.")
255
+ .option("-t, --type <n>", "Thread type: 0=User, 1=Group", "0")
256
+ .option("-c, --cli-msg-id <id>", "Client message ID (required, get from listen --json or send --json)")
257
+ .action(async (msgId, threadId, opts) => {
258
+ try {
259
+ if (!opts.cliMsgId) {
260
+ error("cliMsgId is required for undo. Get it from: listen --json or send --json output.");
261
+ return;
262
+ }
263
+ const payload = { msgId, cliMsgId: opts.cliMsgId };
264
+ const result = await getApi().undo(payload, threadId, Number(opts.type));
265
+ output(result, program.opts().json, () => success("Message recalled (undone)"));
266
+ } catch (e) {
267
+ error(`Undo failed: ${e.message}`);
268
+ }
269
+ });
270
+
242
271
  msg.command("forward <msgId> <threadId>")
243
272
  .description("Forward a message to another thread")
244
273
  .option("-t, --type <n>", "Thread type: 0=User, 1=Group", "0")