📝docs: 更新 Bailys 参考文档

main
LiaoYijun 7 months ago
parent 5873cc947e
commit 9d396c5eb0

@ -3,6 +3,7 @@ const {
Browsers,
DisconnectReason,
fetchLatestBaileysVersion,
getContentType,
makeCacheableSignalKeyStore,
makeInMemoryStore,
useMultiFileAuthState,
@ -20,7 +21,7 @@ const generateId = require('../../utils/generateId.util');
const NodeCache = require('node-cache');
const P = require('pino');
// https://baileys.whiskeysockets.io/
// Reference: https://github.com/WhiskeySockets/Baileys/blob/master/README.md
const createWhatsApp = async phone => {
let qrCode = null;
@ -78,9 +79,10 @@ const createWhatsApp = async phone => {
creds: state.creds,
keys: makeCacheableSignalKeyStore(state.keys, logger),
},
// https://github.com/WhiskeySockets/Baileys/blob/31bc8ab/src/Utils/generics.ts#L21
// https://github.com/WhiskeySockets/Baileys/blob/31bc8ab4e2c825c0d774875701ed07e20d05bdb6/WAProto/WAProto.proto
browser: Browsers.macOS('SAFARI'),//Browsers.macOS('SAFARI'),//Browsers.ubuntu('IOS_PHONE'),//Browsers.baileys('WEAR_OS'),//
// https://github.com/WhiskeySockets/Baileys/blob/master/src/Utils/generics.ts
// https://github.com/WhiskeySockets/Baileys/blob/master/WAProto/WAProto.proto
// Browsers.macOS('SAFARI'), Browsers.ubuntu('IOS_PHONE'), Browsers.baileys('WEAR_OS'),
browser: Browsers.ubuntu('Sales'),
msgRetryCounterCache,
generateHighQualityLinkPreview: false,
syncFullHistory: false,
@ -142,6 +144,9 @@ const createWhatsApp = async phone => {
const getMessageParser = (original) => {
const contentType = getContentType(original);
// ...
if (original.message?.conversation || original.message?.extendedTextMessage?.text) return parseTextMessage;
if (original.message?.imageMessage) return parseImageMessage;
@ -152,6 +157,10 @@ const createWhatsApp = async phone => {
};
const getEventSource = (upsert) => {
// source = prefix + infix + suffix
// prefix: server.name
// infix: upsert/update
// suffix: notify/append...
if (upsert.type === 'notify') {
return serverConfig.name + '.messages.upsert.notify';
} else if (upsert.type === 'append') {

Loading…
Cancel
Save