perf: WA-log 不加 channelId, QR 事件名字更改

dev/supplier-email-drawer
LiaoYijun 9 months ago
parent 5408ad1d04
commit 119c7d0739

@ -30,7 +30,7 @@ const createWhatsApp = async phone => {
const externalIdCache = new NodeCache({ stdTTL: 60*5 }); const externalIdCache = new NodeCache({ stdTTL: 60*5 });
// 缓存群信息,过期时间为 24 小时 // 缓存群信息,过期时间为 24 小时
const groupSubjectCache = new NodeCache({ stdTTL: 60*60*24 }); const groupSubjectCache = new NodeCache({ stdTTL: 60*60*24 });
const logger = P({ timestamp: () => `,"time":"${new Date().toJSON()}"` }, P.destination('./logs/wa-logs-' + phone + '_' + channelId + '.txt')); const logger = P({ timestamp: () => `,"time":"${new Date().toJSON()}"` }, P.destination('./logs/wa-logs-' + phone + '.txt'));
logger.level = 'trace'; logger.level = 'trace';
const msgRetryCounterCache = new NodeCache(); const msgRetryCounterCache = new NodeCache();
const storeFilename = './baileys_auth_info/baileys_store_' + phone + '.json' const storeFilename = './baileys_auth_info/baileys_store_' + phone + '.json'
@ -81,7 +81,7 @@ const createWhatsApp = async phone => {
if (isJidStatusBroadcast(msg.key.remoteJid)) continue; if (isJidStatusBroadcast(msg.key.remoteJid)) continue;
const messageType = Object.keys(msg.message)[0]; const messageType = Object.keys(msg.message)[0];
// 如果是群发(status@broadcast)participant 是发送人,不然则是 remoteJid // 如果是群发(xxx@broadcast)participant 是发送人,不然则是 remoteJid
const remoteNo = isJidBroadcast(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 externalId = externalIdCache.get(msg.key.id);
const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid); const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid);
@ -171,7 +171,7 @@ const createWhatsApp = async phone => {
for (const msg of upsert.messages) { for (const msg of upsert.messages) {
if (msg.message?.conversation || msg.message?.extendedTextMessage?.text) { if (msg.message?.conversation || msg.message?.extendedTextMessage?.text) {
const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text; const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text;
// 如果是群发(status@broadcast)participant 是发送人,不然则是 remoteJid // 如果是群发(xxx@broadcast)participant 是发送人,不然则是 remoteJid
const remoteNo = isJidBroadcast(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 externalId = externalIdCache.get(msg.key.id);
const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid); const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid);
@ -221,7 +221,7 @@ const createWhatsApp = async phone => {
if (ignore) continue; if (ignore) continue;
// 如果是群发(status@broadcast)participant 是发送人,不然则是 remoteJid // 如果是群发(xxx@broadcast)participant 是发送人,不然则是 remoteJid
const remoteNo = isJidBroadcast(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 externalId = externalIdCache.get(msg.key.id);
const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid); const isPersonal = isJidUser(msg.key.remoteJid) || isJidBroadcast(msg.key.remoteJid);
@ -318,8 +318,7 @@ const createWhatsApp = async phone => {
waEmitter.emit('creds:update', { waEmitter.emit('creds:update', {
id: generateId(), id: generateId(),
qr, whatsAppNo, qr, whatsAppNo,
server:serverConfig.name, eventSource: serverConfig.name + '.connection.update.qr',
eventSource: 'creds.update',
createTime: formatTimestamp(new Date().getTime() / 1000), createTime: formatTimestamp(new Date().getTime() / 1000),
}); });
} else { } else {

Loading…
Cancel
Save