MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / handleLocalBotMessage

Function handleLocalBotMessage

plugins/localbot2.ts:422–444  ·  view source on GitHub ↗
(
    sock: any,
    message: any,
    chatId: string,
    text: string,
    senderId: string,
    channelInfo: any
)

Source from the content-addressed store, hash-verified

420};
421
422export 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}

Callers

nothing calls this directly

Calls 1

getResponseFunction · 0.70

Tested by

no test coverage detected