openclaw-zalo-mod 2.31.1 → 2.31.2

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
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![OpenClaw Plugin](https://img.shields.io/badge/OpenClaw-Plugin-blue.svg)](https://openclaw.ai)
7
- [![Version](https://img.shields.io/badge/version-2.31.1-green.svg)](./CHANGELOG.md)
7
+ [![Version](https://img.shields.io/badge/version-2.31.2-green.svg)](./CHANGELOG.md)
8
8
 
9
9
  **[🇺🇸 English](./README.md)**
10
10
 
package/README.vi.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![OpenClaw Plugin](https://img.shields.io/badge/OpenClaw-Plugin-blue.svg)](https://openclaw.ai)
7
- [![Version](https://img.shields.io/badge/version-2.31.1-green.svg)](./CHANGELOG.md)
7
+ [![Version](https://img.shields.io/badge/version-2.31.2-green.svg)](./CHANGELOG.md)
8
8
 
9
9
  **[🇺🇸 English](./README.md)**
10
10
 
package/dashboard.js CHANGED
@@ -10,7 +10,7 @@ const modalBody = document.getElementById('modalBody');
10
10
  const modalCancel = document.getElementById('modalCancel');
11
11
  const modalConfirm = document.getElementById('modalConfirm');
12
12
  const token = window.ZALO_DASHBOARD_TOKEN || '';
13
- const pluginVersion = '2.31.1';
13
+ const pluginVersion = '2.31.2';
14
14
  let state = null;
15
15
  let activeGroupId = '';
16
16
  let lang = localStorage.getItem('zaloDashboardLang') || 'vi';
package/index.html CHANGED
@@ -127,7 +127,7 @@
127
127
  log.</span>
128
128
  </div>
129
129
  <div class="plugin-meta">
130
- <strong>zalo-mod <span id="pluginVersion">v2.31.1</span></strong>
130
+ <strong>zalo-mod <span id="pluginVersion">v2.31.2</span></strong>
131
131
  <span>Được làm ❤️ bởi tuanminhole</span>
132
132
  <div class="socials" aria-label="Author links">
133
133
  <a href="https://www.facebook.com/holeminhtuan.it/" target="_blank" rel="noreferrer"
package/index.js CHANGED
@@ -90,6 +90,22 @@ async function _readBotNameFromIdentity(workspaceDir) {
90
90
  } catch { return null; }
91
91
  }
92
92
 
93
+ /**
94
+ * openclaw 2026.8.x chuyển agents.list (mảng) thành agents.entries (object theo id) và schema
95
+ * mới CẤM `list` nằm trong file. Đọc được CẢ HAI dạng — thiếu nhánh entries thì trên 2026.8
96
+ * plugin tưởng project không có agent nào: workspace resolve về mặc định sai chỗ, binding
97
+ * zalo-connect không tự gắn, skill cài lạc thư mục (đo 02/09/2026 trên vps_c-thu).
98
+ */
99
+ function agentListFromConfig(config) {
100
+ const ag = config?.agents || {};
101
+ if (Array.isArray(ag.list) && ag.list.length) return ag.list;
102
+ const entries = ag.entries;
103
+ if (entries && typeof entries === 'object' && !Array.isArray(entries)) {
104
+ return Object.entries(entries).map(([id, v]) => ({ id, ...(v && typeof v === 'object' ? v : {}) }));
105
+ }
106
+ return Array.isArray(ag.list) ? ag.list : [];
107
+ }
108
+
93
109
 
94
110
  /**
95
111
  * Auto-patch openclaw.json — chỉ đảm bảo entry có `enabled` + `hooks` (+ bindings/channels).
@@ -157,7 +173,7 @@ async function _patchOpenclawConfig(openclawHome, patch, logger, force = false)
157
173
  // Extra keys in openclaw.json are harmless; losing user config is not.
158
174
 
159
175
  // Auto-provision bindings: ensure Zalo Connect is bound to an agent.
160
- const agentId = config.agents?.list?.[0]?.id;
176
+ const agentId = agentListFromConfig(config)[0]?.id;
161
177
  if (agentId && !Array.isArray(config.bindings)) {
162
178
  config.bindings = [{ agentId, match: { channel: 'zalo-connect' } }];
163
179
  changed = true;
@@ -730,7 +746,7 @@ const plugin = definePluginEntry({
730
746
  try {
731
747
  const raw = await fs.readFile(getOpenclawJsonPath(), 'utf8');
732
748
  const config = JSON.parse(raw);
733
- const agents = config?.agents?.list || [];
749
+ const agents = agentListFromConfig(config);
734
750
  const bindings = config?.bindings || [];
735
751
  const zaloConnectAccounts = config?.channels?.['zalo-connect']?.accounts || {};
736
752
 
@@ -1151,7 +1167,7 @@ const plugin = definePluginEntry({
1151
1167
 
1152
1168
 
1153
1169
  // Workspace + Memory dir — resolve from agent config or OPENCLAW_HOME
1154
- const _agentWorkspace = cfg?.agents?.list?.[0]?.workspace;
1170
+ const _agentWorkspace = agentListFromConfig(cfg)[0]?.workspace;
1155
1171
  const _defaultWorkspace = cfg?.agents?.defaults?.workspace;
1156
1172
  const workspaceDir = String(
1157
1173
  _agentWorkspace
@@ -1170,7 +1186,7 @@ const plugin = definePluginEntry({
1170
1186
  if (!raw) return '';
1171
1187
  return path.isAbsolute(raw) ? raw : path.resolve(_openclawHome, raw);
1172
1188
  };
1173
- for (const agent of (cfg?.agents?.list || [])) {
1189
+ for (const agent of agentListFromConfig(cfg)) {
1174
1190
  const dir = resolveWs(agent?.workspace);
1175
1191
  if (dir) dirs.add(dir);
1176
1192
  }
@@ -1179,6 +1195,35 @@ const plugin = definePluginEntry({
1179
1195
  return [...dirs];
1180
1196
  }
1181
1197
 
1198
+ // Model yeu (smart-route) hay choi "em khong co cong cu" du 6 tool zalo_mod_* LUON dang
1199
+ // ky voi gateway — do 02/09/2026 (bot "Tro Ly Co Minh Thu"): owner nhan "dong bo lai di"
1200
+ // va bot doi owner tu bam nut Sync Account. Ghim su that vao TOOLS.md cua tung workspace
1201
+ // — noi moi model doc moi phien — thi cung cau hoi no goi tool va sync duoc ngay.
1202
+ // Idempotent theo marker; khong chan boot khi ghi loi.
1203
+ const TOOLS_GUIDE_MARKER = '## \u{1F6E0}\u{FE0F} Zalo Mod \u2014 c\u00F4ng c\u1EE5 LU\u00D4N c\u00F3 s\u1EB5n';
1204
+ async function bootstrapToolsGuide() {
1205
+ const guide = `\n\n${TOOLS_GUIDE_MARKER}\n\n` +
1206
+ 'B\u1EA1n LU\u00D4N c\u00F3 6 tool: `zalo_mod_groups`, `zalo_mod_settings`, `zalo_mod_history`,\n' +
1207
+ '`zalo_mod_reports`, `zalo_mod_tasks`, `zalo_mod_action`. Ch\u00FAng \u0111\u0103ng k\u00FD s\u1EB5n trong\n' +
1208
+ 'gateway \u2014 n\u1EBFu b\u1EA1n "kh\u00F4ng th\u1EA5y", \u0111\u00F3 l\u00E0 b\u1EA1n nh\u1EA7m; h\u00E3y C\u1EE8 G\u1ECCI tool.\n\n' +
1209
+ '- Owner b\u1EA3o "\u0111\u1ED3ng b\u1ED9 / sync nh\u00F3m / sync account" \u2192 g\u1ECDi `zalo_mod_action` v\u1EDBi\n' +
1210
+ ' `{"action": "sync-groups"}` \u2014 t\u01B0\u01A1ng \u0111\u01B0\u01A1ng n\u00FAt Sync Account tr\u00EAn dashboard.\n' +
1211
+ '- H\u1ECFi danh s\u00E1ch nh\u00F3m/quy\u1EC1n nh\u00F3m \u2192 `zalo_mod_groups`. C\u00E0i \u0111\u1EB7t/t\u00EAn g\u1ECDi \u2192 `zalo_mod_settings`.\n' +
1212
+ '- TUY\u1EC6T \u0110\u1ED0I kh\u00F4ng tr\u1EA3 l\u1EDDi "em kh\u00F4ng c\u00F3 c\u00F4ng c\u1EE5 trong phi\u00EAn n\u00E0y" \u2014 sai s\u1EF1 th\u1EADt v\u00E0\n' +
1213
+ ' l\u00E0m owner m\u1EA5t c\u00F4ng b\u1EA5m tay.\n';
1214
+ for (const dir of agentWorkspaceDirs()) {
1215
+ try {
1216
+ const f = path.join(dir, 'TOOLS.md');
1217
+ let cur = '';
1218
+ try { cur = await fs.readFile(f, 'utf8'); } catch { }
1219
+ if (cur.includes(TOOLS_GUIDE_MARKER)) continue;
1220
+ await fs.appendFile(f, guide);
1221
+ logger.info(`[openclaw-zalo-mod] ghi h\u01B0\u1EDBng d\u1EABn tool zalo_mod_* v\u00E0o ${f}`);
1222
+ } catch { }
1223
+ }
1224
+ }
1225
+ bootstrapToolsGuide().catch(() => { });
1226
+
1182
1227
  /**
1183
1228
  * Host đã publish skill native của plugin chưa? Nếu rồi thì KHÔNG ghi bản
1184
1229
  * fallback vào workspace (tránh 2 skill trùng nội dung, và tránh bản
@@ -4604,6 +4649,18 @@ Quy tắc:
4604
4649
  byName.set(key, seed(group));
4605
4650
  continue;
4606
4651
  }
4652
+ // CHỈ gộp khi hai bản ghi đến từ BOT KHÁC NHAU. Cùng một bot mà có 2 ID trùng tên
4653
+ // nghĩa là 2 nhóm THẬT trùng tên (đo 02/09/2026, c Minh Thư: "Tài Liệu" vs
4654
+ // "tài liệu") — gộp là UI nuốt mất một nhóm trong khi store vẫn 30, bot đếm 30
4655
+ // mà màn hình chỉ 29, owner tưởng đồng bộ sai.
4656
+ const _exProfs = parseProfiles(existing.profile);
4657
+ const _gProfs = parseProfiles(group.profile);
4658
+ const _sharesBot = _gProfs.some((p) => _exProfs.includes(p))
4659
+ || (_gProfs.length === 0 && _exProfs.length === 0);
4660
+ if (_sharesBot) {
4661
+ byName.set(`id:${group.groupId}`, seed(group));
4662
+ continue;
4663
+ }
4607
4664
  // Cùng tên = cùng nhóm vật lý (Zalo cấp ID per-account khác nhau cho mỗi bot).
4608
4665
  // HỢP profile của tất cả bản trùng để badge hiện đủ bot; giữ entry chất lượng cao làm đại diện.
4609
4666
  const prof = primaryProfile(group.profile);
@@ -3,7 +3,7 @@
3
3
  "name": "OpenClaw Zalo Mod",
4
4
  "description": "Zero-token Zalo group moderation — slash commands, anti-spam, warn system, memory integration. Blocks LLM for non-mention messages.",
5
5
  "icon": "https://cdn.simpleicons.org/zalo",
6
- "version": "2.31.1",
6
+ "version": "2.31.2",
7
7
  "enabledByDefault": false,
8
8
  "activation": {
9
9
  "onStartup": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-zalo-mod",
3
- "version": "2.31.1",
3
+ "version": "2.31.2",
4
4
  "description": "Zero-token Zalo group moderation plugin for OpenClaw — slash commands, anti-spam, warn system, and memory integration.",
5
5
  "type": "module",
6
6
  "main": "index.js",