zalo-agent-cli 1.0.13 → 1.0.14
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/group.js +75 -1
package/package.json
CHANGED
package/src/commands/group.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Group commands — list, create, info, members, add/remove-member, rename,
|
|
2
|
+
* Group commands — list, create, info, members, add/remove-member, rename, avatar,
|
|
3
|
+
* admin, owner, block/unblock, settings, leave, join.
|
|
3
4
|
*/
|
|
4
5
|
|
|
6
|
+
import { resolve } from "path";
|
|
5
7
|
import { getApi } from "../core/zalo-client.js";
|
|
6
8
|
import { success, error, info, output } from "../utils/output.js";
|
|
7
9
|
|
|
@@ -97,6 +99,78 @@ export function registerGroupCommands(program) {
|
|
|
97
99
|
}
|
|
98
100
|
});
|
|
99
101
|
|
|
102
|
+
group
|
|
103
|
+
.command("avatar <groupId> <imagePath>")
|
|
104
|
+
.description("Change group avatar")
|
|
105
|
+
.action(async (groupId, imagePath) => {
|
|
106
|
+
try {
|
|
107
|
+
const result = await getApi().changeGroupAvatar(resolve(imagePath), groupId);
|
|
108
|
+
output(result, program.opts().json, () => success("Group avatar changed"));
|
|
109
|
+
} catch (e) {
|
|
110
|
+
error(`Change avatar failed: ${e.message}`);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
group
|
|
115
|
+
.command("add-admin <groupId> <userIds...>")
|
|
116
|
+
.description("Promote members to group admin (deputy)")
|
|
117
|
+
.action(async (groupId, userIds) => {
|
|
118
|
+
try {
|
|
119
|
+
const result = await getApi().addGroupDeputy(userIds, groupId);
|
|
120
|
+
output(result, program.opts().json, () => success("Admin(s) added"));
|
|
121
|
+
} catch (e) {
|
|
122
|
+
error(`Add admin failed: ${e.message}`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
group
|
|
127
|
+
.command("remove-admin <groupId> <userIds...>")
|
|
128
|
+
.description("Demote admins back to regular members")
|
|
129
|
+
.action(async (groupId, userIds) => {
|
|
130
|
+
try {
|
|
131
|
+
const result = await getApi().removeGroupDeputy(userIds, groupId);
|
|
132
|
+
output(result, program.opts().json, () => success("Admin(s) removed"));
|
|
133
|
+
} catch (e) {
|
|
134
|
+
error(`Remove admin failed: ${e.message}`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
group
|
|
139
|
+
.command("transfer-owner <groupId> <userId>")
|
|
140
|
+
.description("Transfer group ownership to another member")
|
|
141
|
+
.action(async (groupId, userId) => {
|
|
142
|
+
try {
|
|
143
|
+
const result = await getApi().changeGroupOwner(userId, groupId);
|
|
144
|
+
output(result, program.opts().json, () => success(`Ownership transferred to ${userId}`));
|
|
145
|
+
} catch (e) {
|
|
146
|
+
error(`Transfer owner failed: ${e.message}`);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
group
|
|
151
|
+
.command("block-member <groupId> <userIds...>")
|
|
152
|
+
.description("Block members from rejoining the group")
|
|
153
|
+
.action(async (groupId, userIds) => {
|
|
154
|
+
try {
|
|
155
|
+
const result = await getApi().addGroupBlockedMember(userIds, groupId);
|
|
156
|
+
output(result, program.opts().json, () => success("Member(s) blocked"));
|
|
157
|
+
} catch (e) {
|
|
158
|
+
error(`Block member failed: ${e.message}`);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
group
|
|
163
|
+
.command("unblock-member <groupId> <userIds...>")
|
|
164
|
+
.description("Unblock previously blocked members")
|
|
165
|
+
.action(async (groupId, userIds) => {
|
|
166
|
+
try {
|
|
167
|
+
const result = await getApi().removeGroupBlockedMember(userIds, groupId);
|
|
168
|
+
output(result, program.opts().json, () => success("Member(s) unblocked"));
|
|
169
|
+
} catch (e) {
|
|
170
|
+
error(`Unblock member failed: ${e.message}`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
100
174
|
group
|
|
101
175
|
.command("leave <groupId>")
|
|
102
176
|
.description("Leave a group")
|