feat: 增加消息类型 conversation.type

dev/supplier-email-drawer
LiaoYijun 9 months ago
parent 32d197121f
commit d983b2254b

@ -7,6 +7,7 @@ const {
makeInMemoryStore,
useMultiFileAuthState,
downloadMediaMessage,
isJidUser
} = require('@whiskeysockets/baileys');
const { writeFile } = require('fs/promises');
const waEmitter = require('../emitter');
@ -41,7 +42,7 @@ waEmitter.on('connection.open', event => {
const createWhatsApp = async phone => {
const channelId = generateId();
const whatsAppNo = phone;
const { state, saveCreds } = await useMultiFileAuthState('baileys_auth_info/' + phone);
const { state, saveCreds } = await useMultiFileAuthState('baileys_auth_info/' + phone + '_' + channelId);
// fetch latest version of WA Web
const { version, isLatest } = await fetchLatestBaileysVersion();
const waVersion = version.join('.') + ', ' + (isLatest ? 'latest' : 'out');
@ -183,6 +184,9 @@ const createWhatsApp = async phone => {
text: {
body: text,
},
conversation: {
type: isJidUser(msg.key.remoteJid) ? 'individual' : 'group',
},
customerProfile: {
id: parsePhoneNumber(msg.key.participant),
name: msg.pushName,
@ -200,6 +204,9 @@ const createWhatsApp = async phone => {
text: {
body: text,
},
conversation: {
type: isJidUser(msg.key.remoteJid) ? 'individual' : 'group',
},
customerProfile: {
id: parsePhoneNumber(msg.key.participant),
name: msg.pushName,
@ -221,6 +228,9 @@ const createWhatsApp = async phone => {
status: formatStatus(msg.update.status),
from: msg.key.fromMe ? whatsAppNo : parsePhoneNumber(msg.key.remoteJid),
to: msg.key.fromMe ? parsePhoneNumber(msg.key.remoteJid) : whatsAppNo,
conversation: {
type: isJidUser(msg.key.remoteJid) ? 'individual' : 'group',
},
customerProfile: {
id: parsePhoneNumber(msg.key.participant),
name: msg.pushName,

Loading…
Cancel
Save