@zhin.js/adapter-icqq 1.1.21 → 1.1.23
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/CHANGELOG.md +67 -0
- package/PERMITS.md +1 -0
- package/README.md +1 -1
- package/adapters/icqq/index.js +96 -25
- package/adapters/icqq/index.ts +97 -27
- package/agents/icqq/messages.js +20 -0
- package/agents/icqq/messages.ts +20 -0
- package/agents/icqq/skills/icqq-group-admin/SKILL.md +5 -0
- package/agents/icqq/skills/icqq-group-admin/tools/announce/index.js +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/announce/index.ts +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/essence/index.js +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/essence/index.ts +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/group_kick/index.js +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/group_kick/index.ts +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/recall_member_message/index.js +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/recall_member_message/index.ts +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/set_group_admin/index.js +43 -0
- package/agents/icqq/skills/icqq-group-admin/tools/set_group_admin/index.ts +36 -0
- package/agents/icqq/skills/icqq-group-admin/tools/set_mute/index.js +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/set_mute/index.ts +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/set_title/index.js +2 -0
- package/agents/icqq/skills/icqq-group-admin/tools/set_title/index.ts +2 -0
- package/lib/endpoint.js +4 -1
- package/lib/group-actions.d.ts +10 -0
- package/lib/group-actions.js +94 -0
- package/lib/icqq-inbound.d.ts +2 -6
- package/lib/icqq-inbound.js +5 -30
- package/lib/outbound-media.js +10 -4
- package/lib/sensitive-commands.d.ts +8 -0
- package/lib/sensitive-commands.js +16 -0
- package/package.json +24 -18
- package/plugin.js +8 -1
- package/src/endpoint.ts +4 -1
- package/src/group-actions.ts +105 -0
- package/src/icqq-inbound.ts +13 -32
- package/src/outbound-media.ts +9 -3
- package/src/sensitive-commands.ts +19 -0
package/src/outbound-media.ts
CHANGED
|
@@ -68,14 +68,19 @@ export function prepareIcqqOutboundMedia(
|
|
|
68
68
|
if (!data || typeof data !== "object") return seg;
|
|
69
69
|
const d = data as Record<string, unknown>;
|
|
70
70
|
const media = d.media;
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
let b64 = "";
|
|
72
|
+
let mime = "";
|
|
73
|
+
if (isMediaRef(media) && media.kind === "base64") {
|
|
74
|
+
b64 = media.value.replace(/^base64:\/\//, "");
|
|
75
|
+
mime = media.mime_type ?? "";
|
|
76
|
+
} else if (typeof d.file === "string" && d.file.startsWith("base64://")) {
|
|
77
|
+
b64 = d.file.slice("base64://".length);
|
|
78
|
+
}
|
|
73
79
|
if (!b64) return seg;
|
|
74
80
|
if (type !== "image" && type !== "record" && type !== "audio" && type !== "video") {
|
|
75
81
|
return seg;
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
const mime = media.mime_type ?? "";
|
|
79
84
|
const filePath = spoolBase64ToFile(
|
|
80
85
|
b64,
|
|
81
86
|
mime || (type === "image" ? "image/jpeg" : type === "video" ? "video/mp4" : "audio/mpeg"),
|
|
@@ -86,6 +91,7 @@ export function prepareIcqqOutboundMedia(
|
|
|
86
91
|
type,
|
|
87
92
|
data: {
|
|
88
93
|
...d,
|
|
94
|
+
...(typeof d.file === "string" && d.file.startsWith("base64://") ? { file: filePath } : {}),
|
|
89
95
|
media: {
|
|
90
96
|
kind: "path",
|
|
91
97
|
value: filePath,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SensitiveExecCommandRule } from '@zhin.js/agent';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `icqq` command-line client can kick members, move money and delete files. Under an `allowlist`
|
|
5
|
+
* exec policy its non-sensitive subcommands run freely, while these need owner approval (ADR 0044:
|
|
6
|
+
* this knowledge lives with the adapter, the exec policy only reads the registered rule).
|
|
7
|
+
*/
|
|
8
|
+
export const ICQQ_SENSITIVE_SUBCOMMAND_REGEXES: readonly RegExp[] = Object.freeze([
|
|
9
|
+
/\bicqq\s+friend\s+(?:delete|block|move)\b/i,
|
|
10
|
+
/\bicqq\s+group\s+(?:kick|mute|set|admin|announce|transfer|quit|dissolve|invite)\b/i,
|
|
11
|
+
/\bicqq\s+(?:request|wallet|pay|recall)\b/i,
|
|
12
|
+
/\bicqq\s+file\s+(?:upload|delete)\b/i,
|
|
13
|
+
/\bicqq\s+gfs\b.*\b(?:rm|delete|del)\b/i,
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export const icqqSensitiveExecRule: SensitiveExecCommandRule = Object.freeze({
|
|
17
|
+
command: 'icqq',
|
|
18
|
+
sensitive: ICQQ_SENSITIVE_SUBCOMMAND_REGEXES,
|
|
19
|
+
});
|