|
|
|
@ -55,6 +55,11 @@ const createWhatsApp = async phone => {
|
|
|
|
|
|
|
|
|
|
const sendTextMessage = async (number, content) => {
|
|
|
|
|
const jid = formatPhoneNumber(number);
|
|
|
|
|
|
|
|
|
|
if (number === whatsAppNo) {
|
|
|
|
|
// whatsAppNo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const msgInfo = await waSocket.sendMessage(jid, { text: content });
|
|
|
|
|
waSocket.sendMessage(jid, { text: content })
|
|
|
|
@ -279,7 +284,7 @@ const createWhatsApp = async phone => {
|
|
|
|
|
console.log('Connection closed: ', lastDisconnect);
|
|
|
|
|
|
|
|
|
|
waEmitter.emit('connection:close', {
|
|
|
|
|
whatsAppNo,
|
|
|
|
|
whatsAppNo, channelId,
|
|
|
|
|
eventSource: 'connection.update.close',
|
|
|
|
|
status: 'offline',
|
|
|
|
|
});
|
|
|
|
@ -288,7 +293,7 @@ const createWhatsApp = async phone => {
|
|
|
|
|
// 扫码成功后向这个群发消息,后续就能使用 API 发送了。
|
|
|
|
|
sendTextMessage('120363363417115199@g.us', whatsAppNo + ' 登录成功:' + new Date().toString());
|
|
|
|
|
waEmitter.emit('connection:open', {
|
|
|
|
|
status: 'open', whatsAppNo,
|
|
|
|
|
status: 'open', whatsAppNo, channelId,
|
|
|
|
|
eventSource: 'connection.update.open',
|
|
|
|
|
});
|
|
|
|
|
} else if (qr !== undefined) {
|
|
|
|
|