@jackle.dev/zalox-plugin 1.0.2 → 1.0.4
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/channel.ts +12 -3
- package/src/send.ts +15 -8
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -110,7 +110,8 @@ export const zaloxPlugin: ChannelPlugin<ResolvedZaloxAccount> = {
|
|
|
110
110
|
blockStreaming: true,
|
|
111
111
|
},
|
|
112
112
|
reload: { configPrefixes: ['channels.zalox'] },
|
|
113
|
-
configSchema: buildChannelConfigSchema(ZaloxConfigSchema),
|
|
113
|
+
// configSchema: buildChannelConfigSchema(ZaloxConfigSchema), // Disabled due to runtime Zod version mismatch
|
|
114
|
+
configSchema: undefined,
|
|
114
115
|
|
|
115
116
|
// ── Config ────────────────────────────────────────────
|
|
116
117
|
config: {
|
|
@@ -248,7 +249,11 @@ export const zaloxPlugin: ChannelPlugin<ResolvedZaloxAccount> = {
|
|
|
248
249
|
sendText: async ({ to, text, accountId, cfg }) => {
|
|
249
250
|
const account = resolveAccount({ cfg, accountId });
|
|
250
251
|
const profile = resolveProfile(account.config, account.accountId);
|
|
251
|
-
|
|
252
|
+
|
|
253
|
+
const isGroup = to.startsWith('group:');
|
|
254
|
+
const cleanTo = to.replace(/^group:/, '');
|
|
255
|
+
|
|
256
|
+
const result = await sendText(cleanTo, text, { profile, isGroup });
|
|
252
257
|
return {
|
|
253
258
|
channel: 'zalox',
|
|
254
259
|
ok: result.ok,
|
|
@@ -259,7 +264,11 @@ export const zaloxPlugin: ChannelPlugin<ResolvedZaloxAccount> = {
|
|
|
259
264
|
sendMedia: async ({ to, text, mediaUrl, accountId, cfg }) => {
|
|
260
265
|
const account = resolveAccount({ cfg, accountId });
|
|
261
266
|
const profile = resolveProfile(account.config, account.accountId);
|
|
262
|
-
|
|
267
|
+
|
|
268
|
+
const isGroup = to.startsWith('group:');
|
|
269
|
+
const cleanTo = to.replace(/^group:/, '');
|
|
270
|
+
|
|
271
|
+
const result = await sendMedia(cleanTo, text ?? '', mediaUrl ?? '', { profile, isGroup });
|
|
263
272
|
return {
|
|
264
273
|
channel: 'zalox',
|
|
265
274
|
ok: result.ok,
|
package/src/send.ts
CHANGED
|
@@ -95,14 +95,21 @@ export async function sendMedia(
|
|
|
95
95
|
tmpPath = `/tmp/${filename}`;
|
|
96
96
|
writeFileSync(tmpPath, buffer);
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
try {
|
|
99
|
+
const result = await cached.api.sendMessage(
|
|
100
|
+
{ msg: text || '', attachments: [tmpPath] },
|
|
101
|
+
threadId.trim(),
|
|
102
|
+
type,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const msgId = result?.message?.msgId ? String(result.message.msgId) : undefined;
|
|
106
|
+
return { ok: true, messageId: msgId };
|
|
107
|
+
} catch (sendErr) {
|
|
108
|
+
console.error(`[ZaloX] Send attachment failed: ${sendErr}`);
|
|
109
|
+
// Fallback: send text with URL as link
|
|
110
|
+
const fullText = text ? `${text}\n${mediaUrl}` : mediaUrl;
|
|
111
|
+
return sendText(threadId, fullText, options);
|
|
112
|
+
}
|
|
106
113
|
} catch (dlErr: any) {
|
|
107
114
|
// Fallback: send text with URL as link
|
|
108
115
|
const fullText = text ? `${text}\n${mediaUrl}` : mediaUrl;
|