Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { store, bot } from './../index.js'
- import { isJidGroup, isPnUser, getContentType, normalizeMessageContent } from 'baileys'
- export default async function (m) {
- //let m = structuredClone(mOri)
- m.message = normalizeMessageContent(m.message)
- // m.text
- const text =
- // human
- m.message?.conversation || // text
- m.message?.extendedTextMessage?.text || // teks + dll
- m.message?.imageMessage?.caption || // gambar
- m.message?.videoMessage?.caption || // video
- /* bot */
- m.message?.buttonsResponseMessage?.selectedDisplayText ||
- null
- // m.key
- const key = m.key
- // m.message
- const message = m.message
- // m.pushName
- const pushName = m.pushName
- // m.type
- const type = getContentType(message)
- // m.chatId
- const chatId = m.key.remoteJid
- // m.chatId
- const here = m.key.remoteJid
- // m.senderId
- const senderId = m.key.participant || (m.key.fromMe ? bot.id : m.key.senderLid)
- // QUOTED
- const qctx = m.message?.[type]?.contextInfo
- const q_message = normalizeMessageContent(qctx?.quotedMessage)
- let q = null
- if (q_message) {
- // mapping pn to lid
- if (isPnUser(qctx?.participant)) {
- console.log('😲 mapping pn to lid')
- qctx.participant = (await sock.signalRepository.lidMapping.pnToLIDFunc([qctx.participant]))?.[0]?.lid
- }
- // m.q.text
- const q_text =
- // human
- q_message?.conversation || // text
- q_message?.extendedTextMessage?.text || // text + dll
- q_message?.imageMessage?.caption || // gambar
- q_message?.videoMessage?.caption || //video
- // bot
- q_message?.buttonsMessage?.contentText || null
- // m.q.pushName
- const q_pushName = store.contacts_new.get(qctx?.participant)?.notify || null
- // m.q.type
- const q_type = getContentType(q_message) || null
- // m.q.key
- const q_key = {
- remoteJid: q_message ? m.key.remoteJid : null,
- id: qctx?.stanzaId || null,
- participant: isJidGroup(m.key.remoteJid) ? qctx?.participant : null
- }
- // m.q.sender
- const q_senderId = qctx?.participant || null
- q = {
- text: q_text,
- pushName: q_pushName,
- type: q_type,
- key: q_key,
- message: q_message,
- senderId: q_senderId
- }
- }
- const result = {
- key,
- message,
- pushName,
- type,
- text,
- chatId,
- here,
- senderId,
- q
- }
- return result
- }
Add Comment
Please, Sign In to add comment