squidclaw 0.8.0 → 0.8.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/lib/engine.js +21 -1
- package/package.json +1 -1
package/lib/engine.js
CHANGED
|
@@ -213,7 +213,22 @@ export class SquidclawEngine {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
// Show typing indicator while processing
|
|
217
|
+
const chatId = metadata.chatId || contactId;
|
|
218
|
+
const botInfo = this.telegramManager?.bots?.values()?.next()?.value;
|
|
219
|
+
let typingInterval;
|
|
220
|
+
if (botInfo) {
|
|
221
|
+
const sendTyping = () => { try { botInfo.bot.api.sendChatAction(chatId, 'typing').catch(() => {}); } catch {} };
|
|
222
|
+
sendTyping();
|
|
223
|
+
typingInterval = setInterval(sendTyping, 4000);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let result;
|
|
227
|
+
try {
|
|
228
|
+
result = await agent.processMessage(contactId, message, metadata);
|
|
229
|
+
} finally {
|
|
230
|
+
if (typingInterval) clearInterval(typingInterval);
|
|
231
|
+
}
|
|
217
232
|
|
|
218
233
|
if (result.reaction && metadata.messageId) {
|
|
219
234
|
try { await this.telegramManager.sendReaction(agentId, contactId, metadata.messageId, result.reaction, metadata); } catch {}
|
|
@@ -225,9 +240,14 @@ export class SquidclawEngine {
|
|
|
225
240
|
const photoData = result.image.url ? { url: result.image.url } : { base64: result.image.base64 };
|
|
226
241
|
const caption = result.messages?.[0] || '';
|
|
227
242
|
await this.telegramManager.sendPhoto(agentId, contactId, photoData, caption, metadata);
|
|
243
|
+
} else {
|
|
244
|
+
// Send image if generated
|
|
245
|
+
if (result.image) {
|
|
246
|
+
await this.telegramManager.sendPhoto(agentId, contactId, result.image, result.messages?.[0] || '', metadata);
|
|
228
247
|
} else {
|
|
229
248
|
await this.telegramManager.sendMessages(agentId, contactId, result.messages, metadata);
|
|
230
249
|
}
|
|
250
|
+
}
|
|
231
251
|
}
|
|
232
252
|
};
|
|
233
253
|
|