mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-10-15 16:29:17 +00:00
fix: clear typing indicator after sending reply in self-chat mode
This commit is contained in:
parent
7c653c9d56
commit
18c5716d10
3 changed files with 10 additions and 4 deletions
|
|
@ -258,6 +258,9 @@ async def send_wa_reply(
|
|||
except Exception as e:
|
||||
PrintStyle.warning(f"WhatsApp: attachment error: {e}")
|
||||
|
||||
# Clear typing indicator
|
||||
await wa_client.send_typing(base_url, chat_id, paused=True)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,12 +56,15 @@ async def send_media(
|
|||
return await resp.json()
|
||||
|
||||
|
||||
async def send_typing(base_url: str, chat_id: str) -> None:
|
||||
async def send_typing(base_url: str, chat_id: str, paused: bool = False) -> None:
|
||||
try:
|
||||
payload: dict = {"chatId": chat_id}
|
||||
if paused:
|
||||
payload["status"] = "paused"
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(
|
||||
f"{base_url}/typing",
|
||||
json={"chatId": chat_id},
|
||||
json=payload,
|
||||
timeout=aiohttp.ClientTimeout(total=5),
|
||||
) as resp:
|
||||
await resp.json()
|
||||
|
|
|
|||
|
|
@ -547,11 +547,11 @@ app.post('/typing', async (req, res) => {
|
|||
return res.status(503).json({ error: 'Not connected' });
|
||||
}
|
||||
|
||||
const { chatId } = req.body;
|
||||
const { chatId, status } = req.body;
|
||||
if (!chatId) return res.status(400).json({ error: 'chatId required' });
|
||||
|
||||
try {
|
||||
await sock.sendPresenceUpdate('composing', chatId);
|
||||
await sock.sendPresenceUpdate(status === 'paused' ? 'paused' : 'composing', chatId);
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
res.json({ success: false });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue