zalo-agent-cli 1.0.6 → 1.0.7
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 +16 -0
package/package.json
CHANGED
package/src/commands/msg.js
CHANGED
|
@@ -13,10 +13,26 @@ 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("--react <icon>", "Auto-react to the sent message (e.g. :> for haha)")
|
|
16
17
|
.action(async (threadId, message, opts) => {
|
|
17
18
|
try {
|
|
19
|
+
// Capture clientId before send — zca-js uses Date.now() internally
|
|
20
|
+
const cliMsgId = String(Date.now());
|
|
18
21
|
const result = await getApi().sendMessage(message, threadId, Number(opts.type));
|
|
22
|
+
// Include cliMsgId in output for later use with react command
|
|
23
|
+
result.cliMsgId = cliMsgId;
|
|
19
24
|
output(result, program.opts().json, () => success("Message sent"));
|
|
25
|
+
|
|
26
|
+
// Auto-react if --react flag provided
|
|
27
|
+
if (opts.react && result.message?.msgId) {
|
|
28
|
+
const dest = {
|
|
29
|
+
data: { msgId: String(result.message.msgId), cliMsgId },
|
|
30
|
+
threadId,
|
|
31
|
+
type: Number(opts.type),
|
|
32
|
+
};
|
|
33
|
+
await getApi().addReaction(opts.react, dest);
|
|
34
|
+
success(`Auto-reacted with '${opts.react}'`);
|
|
35
|
+
}
|
|
20
36
|
} catch (e) {
|
|
21
37
|
error(e.message);
|
|
22
38
|
}
|