openzca 0.1.29 → 0.1.31

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.
Files changed (2) hide show
  1. package/dist/cli.js +56 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1566,6 +1566,10 @@ function parseRecentMessageTs(value) {
1566
1566
  if (Number.isFinite(parsed)) {
1567
1567
  return Math.trunc(parsed);
1568
1568
  }
1569
+ const parsedDate = Date.parse(trimmed);
1570
+ if (Number.isFinite(parsedDate)) {
1571
+ return Math.trunc(parsedDate);
1572
+ }
1569
1573
  }
1570
1574
  return 0;
1571
1575
  }
@@ -3269,10 +3273,18 @@ msg.command("recent <threadId>").option("-g, --group", "List recent messages for
3269
3273
  const rows = messages.map((message) => ({
3270
3274
  msgId: message.data.msgId,
3271
3275
  cliMsgId: message.data.cliMsgId,
3276
+ threadId: message.threadId || threadId,
3277
+ threadType: message.type === ThreadType.Group ? "group" : "user",
3272
3278
  senderId: message.data.uidFrom,
3273
3279
  senderName: message.data.dName,
3274
3280
  ts: message.data.ts,
3275
3281
  msgType: message.data.msgType,
3282
+ undo: {
3283
+ msgId: message.data.msgId,
3284
+ cliMsgId: message.data.cliMsgId,
3285
+ threadId: message.threadId || threadId,
3286
+ group: message.type === ThreadType.Group
3287
+ },
3276
3288
  content: typeof message.data.content === "string" ? message.data.content : JSON.stringify(message.data.content)
3277
3289
  }));
3278
3290
  if (opts.json) {
@@ -3394,13 +3406,53 @@ group.command("members <groupId>").option("-j, --json", "JSON output").descripti
3394
3406
  if (!groupInfo) {
3395
3407
  throw new Error(`Group not found: ${groupId}`);
3396
3408
  }
3397
- const ids = groupInfo.memberIds ?? [];
3409
+ const normalizeMemberId = (value) => {
3410
+ if (typeof value === "number" && Number.isFinite(value)) {
3411
+ return String(Math.trunc(value));
3412
+ }
3413
+ if (typeof value !== "string") return "";
3414
+ const trimmed = value.trim();
3415
+ if (!trimmed) return "";
3416
+ return trimmed.replace(/_\d+$/, "");
3417
+ };
3418
+ const idsFromMemberIds = Array.isArray(groupInfo.memberIds) ? groupInfo.memberIds.map((id) => normalizeMemberId(id)).filter(Boolean) : [];
3419
+ const memVerList = groupInfo.memVerList;
3420
+ const idsFromMemVerList = Array.isArray(memVerList) ? memVerList.map((id) => normalizeMemberId(id)).filter(Boolean) : [];
3421
+ const currentMems = Array.isArray(groupInfo.currentMems) ? groupInfo.currentMems : [];
3422
+ const currentMemberMap = /* @__PURE__ */ new Map();
3423
+ for (const member of currentMems) {
3424
+ const userId = normalizeMemberId(member.id);
3425
+ if (!userId) continue;
3426
+ currentMemberMap.set(userId, {
3427
+ displayName: member.dName?.trim() || member.zaloName?.trim() || "",
3428
+ zaloName: member.zaloName?.trim() || ""
3429
+ });
3430
+ }
3431
+ const ids = Array.from(
3432
+ /* @__PURE__ */ new Set([
3433
+ ...idsFromMemberIds,
3434
+ ...idsFromMemVerList,
3435
+ ...Array.from(currentMemberMap.keys())
3436
+ ])
3437
+ );
3398
3438
  const profiles = ids.length > 0 ? await api.getGroupMembersInfo(ids) : { profiles: {} };
3399
- const profileMap = profiles.profiles;
3439
+ const rawProfileMap = profiles.profiles;
3440
+ const profileMap = /* @__PURE__ */ new Map();
3441
+ for (const [key, profile] of Object.entries(rawProfileMap)) {
3442
+ if (!profile) continue;
3443
+ const normalizedKey = normalizeMemberId(key);
3444
+ if (normalizedKey && !profileMap.has(normalizedKey)) {
3445
+ profileMap.set(normalizedKey, profile);
3446
+ }
3447
+ const profileId = normalizeMemberId(profile.id);
3448
+ if (profileId && !profileMap.has(profileId)) {
3449
+ profileMap.set(profileId, profile);
3450
+ }
3451
+ }
3400
3452
  const rows = ids.map((id) => ({
3401
3453
  userId: id,
3402
- displayName: profileMap[id]?.displayName ?? "",
3403
- zaloName: profileMap[id]?.zaloName ?? ""
3454
+ displayName: profileMap.get(id)?.displayName ?? currentMemberMap.get(id)?.displayName ?? "",
3455
+ zaloName: profileMap.get(id)?.zaloName ?? currentMemberMap.get(id)?.zaloName ?? ""
3404
3456
  }));
3405
3457
  if (opts.json) {
3406
3458
  output(rows, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzca",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "Open-source zca-compatible CLI to integrate Zalo with OpenClaw",
5
5
  "type": "module",
6
6
  "bin": {