(
sock: any,
message: any,
chatId: string,
text: string,
senderId: string,
channelInfo: any
)
| 420 | }; |
| 421 | |
| 422 | export async function handleLocalBotMessage( |
| 423 | sock: any, |
| 424 | message: any, |
| 425 | chatId: string, |
| 426 | text: string, |
| 427 | senderId: string, |
| 428 | channelInfo: any |
| 429 | ): Promise<boolean> { |
| 430 | const state = chatState.get(chatId); |
| 431 | if (!state?.enabled) return false; |
| 432 | if (!text || /^[.!/]/.test(text.trim())) return false; |
| 433 | if (Date.now() - state.lastActivity > 86400000) { chatState.delete(chatId); return false; } |
| 434 | state.lastActivity = Date.now(); |
| 435 | try { |
| 436 | const senderName = (message.pushName || senderId.split('@')[0] || 'there').split(' ')[0]; |
| 437 | await sock.presenceSubscribe(chatId); |
| 438 | await sock.sendPresenceUpdate('composing', chatId); |
| 439 | await new Promise(r => setTimeout(r, 600 + Math.random() * 1000)); |
| 440 | await sock.sendPresenceUpdate('paused', chatId); |
| 441 | await sock.sendMessage(chatId, { text: await getResponse(text, senderName), ...channelInfo }, { quoted: message }); |
| 442 | } catch {} |
| 443 | return true; |
| 444 | } |
nothing calls this directly
no test coverage detected