|
|
|
@ -7,7 +7,7 @@ const {
|
|
|
|
|
makeInMemoryStore,
|
|
|
|
|
useMultiFileAuthState,
|
|
|
|
|
downloadMediaMessage,
|
|
|
|
|
isJidUser, isJidGroup
|
|
|
|
|
isJidUser, isJidGroup, isJidBroadcast
|
|
|
|
|
} = require('@whiskeysockets/baileys');
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
const path = require('path');
|
|
|
|
@ -80,12 +80,12 @@ const createWhatsApp = async phone => {
|
|
|
|
|
|
|
|
|
|
const messageType = Object.keys(msg.message)[0];
|
|
|
|
|
// 如果是群发(status@broadcast),participant 是发送人,不然则是 remoteJid
|
|
|
|
|
const remoteNo = isJidStatusBroadcast(msg.key.remoteJid) ? decodeJid(msg.key.participant) : decodeJid(msg.key.remoteJid);
|
|
|
|
|
const remoteNo = isJidBroadcast(msg.key.remoteJid) ? decodeJid(msg.key.participant) : decodeJid(msg.key.remoteJid);
|
|
|
|
|
const externalId = externalIdCache.get(msg.key.id);
|
|
|
|
|
const isPersonal = isJidUser(msg.key.remoteJid) || isJidStatusBroadcast(msg.key.remoteJid);
|
|
|
|
|
const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid);
|
|
|
|
|
const conversationType = isPersonal ? 'individual' : 'group';
|
|
|
|
|
const isGroup = isJidGroup(msg.key.remoteJid);
|
|
|
|
|
let groupSubject = groupSubjectCache.get(msg.key.remoteJid);
|
|
|
|
|
let groupSubject = groupSubjectCache.get(msg.key.remoteJid);
|
|
|
|
|
if (isGroup && groupSubject === undefined) {
|
|
|
|
|
const groupMetadata = await waSocket.groupMetadata(msg.key.remoteJid);
|
|
|
|
|
groupSubject = groupMetadata.subject;
|
|
|
|
@ -170,9 +170,9 @@ const createWhatsApp = async phone => {
|
|
|
|
|
if (msg.message?.conversation || msg.message?.extendedTextMessage?.text) {
|
|
|
|
|
const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text;
|
|
|
|
|
// 如果是群发(status@broadcast),participant 是发送人,不然则是 remoteJid
|
|
|
|
|
const remoteNo = isJidStatusBroadcast(msg.key.remoteJid) ? decodeJid(msg.key.participant) : decodeJid(msg.key.remoteJid);
|
|
|
|
|
const remoteNo = isJidBroadcast(msg.key.remoteJid) ? decodeJid(msg.key.participant) : decodeJid(msg.key.remoteJid);
|
|
|
|
|
const externalId = externalIdCache.get(msg.key.id);
|
|
|
|
|
const isPersonal = isJidUser(msg.key.remoteJid) || isJidStatusBroadcast(msg.key.remoteJid);
|
|
|
|
|
const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid);
|
|
|
|
|
const conversationType = isPersonal ? 'individual' : 'group';
|
|
|
|
|
|
|
|
|
|
const emitEventName = msg.key.fromMe ? 'message:updated' : 'message:received';
|
|
|
|
@ -220,9 +220,9 @@ const createWhatsApp = async phone => {
|
|
|
|
|
if (ignore) continue;
|
|
|
|
|
|
|
|
|
|
// 如果是群发(status@broadcast),participant 是发送人,不然则是 remoteJid
|
|
|
|
|
const remoteNo = isJidStatusBroadcast(msg.key.remoteJid) ? decodeJid(msg.key.participant) : decodeJid(msg.key.remoteJid);
|
|
|
|
|
const remoteNo = isJidBroadcast(msg.key.remoteJid) ? decodeJid(msg.key.participant) : decodeJid(msg.key.remoteJid);
|
|
|
|
|
const externalId = externalIdCache.get(msg.key.id);
|
|
|
|
|
const isPersonal = isJidUser(msg.key.remoteJid) || isJidStatusBroadcast(msg.key.remoteJid);
|
|
|
|
|
const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid);
|
|
|
|
|
const conversationType = isPersonal ? 'individual' : 'group';
|
|
|
|
|
|
|
|
|
|
const msgDirection = msg.key.fromMe ? 'outbound' : 'inbound';
|
|
|
|
|