zalo-agent-cli 1.0.20 → 1.0.22

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 CHANGED
@@ -166,6 +166,7 @@ zalo-agent whoami
166
166
  | `msg send-card <threadId> <userId> [-t 0\|1] [--phone NUM]` | Send contact card |
167
167
  | `msg send-bank <threadId> <accountNum> -b BANK [-n name] [-t 0\|1]` | Send bank card |
168
168
  | `msg send-qr-transfer <threadId> <accountNum> -b BANK [-a amount] [-m content] [--template tpl]` | Send VietQR transfer image |
169
+ | `msg send-video <threadId> <videoUrl> --thumb <thumbUrl> [-m caption] [-d ms] [-W px] [-H px]` | Send video from URL |
169
170
  | `msg sticker <threadId> <keyword> [-t 0\|1]` | Search and send sticker |
170
171
  | `msg react <msgId> <threadId> <emoji> [-t 0\|1]` | React to a message |
171
172
  | `msg delete <msgId> <threadId> [-t 0\|1]` | Delete a message |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zalo-agent-cli",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "CLI tool for Zalo automation — multi-account, proxy support, bank transfers, QR payments",
5
5
  "type": "module",
6
6
  "bin": {
@@ -217,6 +217,35 @@ export function registerMsgCommands(program) {
217
217
  }
218
218
  });
219
219
 
220
+ msg.command("send-video <threadId> <videoUrl>")
221
+ .description("Send a video from URL")
222
+ .requiredOption("--thumb <url>", "Thumbnail image URL")
223
+ .option("-t, --type <n>", "Thread type: 0=User, 1=Group", "0")
224
+ .option("-m, --caption <text>", "Caption text", "")
225
+ .option("-d, --duration <ms>", "Video duration in milliseconds", parseInt)
226
+ .option("-W, --width <px>", "Video width", parseInt, 1280)
227
+ .option("-H, --height <px>", "Video height", parseInt, 720)
228
+ .action(async (threadId, videoUrl, opts) => {
229
+ try {
230
+ info(`Sending video: ${videoUrl}`);
231
+ const result = await getApi().sendVideo(
232
+ {
233
+ videoUrl,
234
+ thumbnailUrl: opts.thumb,
235
+ msg: opts.caption,
236
+ duration: opts.duration,
237
+ width: opts.width,
238
+ height: opts.height,
239
+ },
240
+ threadId,
241
+ Number(opts.type),
242
+ );
243
+ output(result, program.opts().json, () => success(`Video sent to ${threadId}`));
244
+ } catch (e) {
245
+ error(`Send video failed: ${e.message}`);
246
+ }
247
+ });
248
+
220
249
  msg.command("react <msgId> <threadId> <reaction>")
221
250
  .description(
222
251
  "React to a message. Reaction codes: :> (haha), /-heart (heart), /-strong (like), :o (wow), :-(( (cry), :-h (angry)",
@@ -102,8 +102,18 @@ export function registerProfileCommands(program) {
102
102
  const bio = result?.profile?.status || "(empty)";
103
103
  output({ bio }, program.opts().json, () => info(`Bio: ${bio}`));
104
104
  } else {
105
- const result = await getApi().updateProfileBio(text);
106
- output(result, program.opts().json, () => success(`Bio updated to: "${text}"`));
105
+ await getApi().updateProfileBio(text);
106
+ // Verify by reading back (Zalo may cache, so check)
107
+ const verify = await getApi().fetchAccountInfo();
108
+ const newBio = verify?.profile?.status || "";
109
+ if (newBio === text) {
110
+ output({ bio: newBio }, program.opts().json, () => success(`Bio updated to: "${text}"`));
111
+ } else {
112
+ output({ bio: newBio, requested: text }, program.opts().json, () => {
113
+ success(`Bio update request sent: "${text}"`);
114
+ info("Note: Zalo may take time to reflect changes, or bio may not be supported for your account type.");
115
+ });
116
+ }
107
117
  }
108
118
  } catch (e) {
109
119
  error(`Bio update failed: ${e.message}`);
@@ -125,10 +135,16 @@ export function registerProfileCommands(program) {
125
135
  // Fetch current profile to fill missing fields (API requires all 3)
126
136
  const current = await getApi().fetchAccountInfo();
127
137
  const p = current?.profile || {};
138
+ // Convert sdob (DD/MM/YYYY) to YYYY-MM-DD format required by API
139
+ let currentDob = "2000-01-01";
140
+ if (p.sdob) {
141
+ const parts = p.sdob.split("/");
142
+ if (parts.length === 3) currentDob = `${parts[2]}-${parts[1]}-${parts[0]}`;
143
+ }
128
144
  const payload = {
129
145
  profile: {
130
146
  name: opts.name || p.displayName || p.zaloName,
131
- dob: opts.dob || p.sdob || "2000-01-01",
147
+ dob: opts.dob || currentDob,
132
148
  gender: opts.gender !== undefined ? Number(opts.gender) : p.gender ?? 0,
133
149
  },
134
150
  };