Merge remote-tracking branch 'origin/main'

dev/supplier-email-drawer
Lei OT 9 months ago
commit ad3c732125

@ -11,8 +11,6 @@ import {
import NodeCache from 'node-cache'
import P from 'pino'
import fs from "fs"
const logger = P({ timestamp: () => `,"time":"${new Date().toJSON()}"` }, P.destination('./wa-logs.txt'))
logger.level = 'trace'
@ -35,16 +33,17 @@ const startSock = async () => {
const channelId = '创建时赋值,唯一标识'
const phone = '手机号'
const createTimestamp = '创建时间戳'
const status = 'close, open, connecting'
const status = 'close, open, connecting, online'
const waVersion = 'v2.3000.1017531287, latest(out)'
const sendTextMessage = (whatsAppNo, content) => {
sock.sendMessage(whatsAppNo + '@s.whatsapp.net', { text: content })
}
const sendImageMessage = (whatsAppNo, content) => {
const sendImageMessage = (whatsAppNo, imageUrl) => {
sock.sendMessage(whatsAppNo + '@s.whatsapp.net', {
image: { url: 'https://images.asiahighlights.com/allpicture/2022/07/8a7d9ced5936463bb904c82a_cut_750x850_349.webp'},//fs.readFileSync("d:\\Workspace\\1.jpg"),
})
image: { url: imageUrl},
})
}
const { state, saveCreds } = await useMultiFileAuthState('baileys_auth_info')
@ -62,11 +61,6 @@ const startSock = async () => {
},
msgRetryCounterCache,
generateHighQualityLinkPreview: true,
// ignore all broadcast messages -- to receive the same
// comment the line below out
// shouldIgnoreJid: jid => isJidBroadcast(jid),
// implement to handle retries & poll updates
getMessage,
})
sock.ev.on('connection.update', (update) => {
@ -89,7 +83,7 @@ const startSock = async () => {
const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text
if (text.indexOf('图片') > -1){
sendImageMessage('8617607730395', '文本消息' + new Date().toString())
sendImageMessage('8617607730395', 'https://images.asiahighlights.com/allpicture/2022/07/8a7d9ced5936463bb904c82a_cut_750x850_349.webp')
} else if (text.indexOf('文本') > -1){
sendTextMessage('8617607730395', '文本消息' + new Date().toString())
}
@ -99,7 +93,7 @@ const startSock = async () => {
})
// 不绑定不会影响扫码登录
// store?.bind(sock.ev)
store?.bind(sock.ev)
// the process function lets you process all events that just occurred
// efficiently in a batch
@ -167,16 +161,6 @@ const startSock = async () => {
)
return sock
async function getMessage(key) {
if (store) {
const msg = await store.loadMessage(key.remoteJid, key.id)
return msg?.message || undefined
}
// only if store is present
return WAProto.Message.fromObject({})
}
}
startSock()

Loading…
Cancel
Save