@ascegu/teamily 1.0.10 → 1.0.11
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 +24 -0
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -237,6 +237,8 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
|
|
|
237
237
|
|
|
238
238
|
log?.info?.(`Starting Teamily channel (account: ${accountId})`);
|
|
239
239
|
|
|
240
|
+
const MEDIA_MAX_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
241
|
+
|
|
240
242
|
const stopFn = startTeamilyMonitoring(account, async (message) => {
|
|
241
243
|
const rt = getTeamilyRuntime();
|
|
242
244
|
const currentCfg = rt.config.loadConfig();
|
|
@@ -255,6 +257,26 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
|
|
|
255
257
|
mediaUrl = message.content.audio.sourceUrl;
|
|
256
258
|
}
|
|
257
259
|
|
|
260
|
+
// Download remote media to a local temp file so the agent recognises
|
|
261
|
+
// image-only messages (hasMediaAttachment checks MediaPath, not MediaUrl).
|
|
262
|
+
let mediaPath: string | undefined;
|
|
263
|
+
let mediaType: string | undefined;
|
|
264
|
+
if (mediaUrl) {
|
|
265
|
+
try {
|
|
266
|
+
const fetched = await rt.channel.media.fetchRemoteMedia({ url: mediaUrl, maxBytes: MEDIA_MAX_BYTES });
|
|
267
|
+
const saved = await rt.channel.media.saveMediaBuffer(
|
|
268
|
+
fetched.buffer,
|
|
269
|
+
fetched.contentType,
|
|
270
|
+
"inbound",
|
|
271
|
+
MEDIA_MAX_BYTES,
|
|
272
|
+
);
|
|
273
|
+
mediaPath = saved.path;
|
|
274
|
+
mediaType = saved.contentType;
|
|
275
|
+
} catch (err) {
|
|
276
|
+
log?.warn?.(`[${accountId}] Failed to download Teamily media: ${String(err)}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
258
280
|
const msgCtx = {
|
|
259
281
|
Body: text,
|
|
260
282
|
From: from,
|
|
@@ -265,6 +287,8 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
|
|
|
265
287
|
OriginatingTo: from,
|
|
266
288
|
ChatType: isGroup ? "group" : "direct",
|
|
267
289
|
MediaUrl: mediaUrl,
|
|
290
|
+
MediaPath: mediaPath,
|
|
291
|
+
MediaType: mediaType,
|
|
268
292
|
};
|
|
269
293
|
|
|
270
294
|
await rt.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|