|
|
|
@ -54,7 +54,10 @@ const createWhatsApp = async phone => {
|
|
|
|
|
const sendTextMessage = (whatsAppNo, content) => {
|
|
|
|
|
const number = formatPhoneNumber(whatsAppNo);
|
|
|
|
|
try {
|
|
|
|
|
waSocket.sendMessage(number, { text: content });
|
|
|
|
|
waSocket.sendMessage(number, { text: content })
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
console.info('发送文本消息出错', ex)
|
|
|
|
|
});
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
waEmitter.emit('message.error', {
|
|
|
|
|
messge: '发送文本消息出错',
|
|
|
|
@ -69,6 +72,9 @@ const createWhatsApp = async phone => {
|
|
|
|
|
try {
|
|
|
|
|
waSocket.sendMessage(number, {
|
|
|
|
|
image: { url: imageUrl },
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
console.info('发送图片消息出错', ex)
|
|
|
|
|
});
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
waEmitter.emit('message.error', {
|
|
|
|
@ -253,8 +259,8 @@ const createWhatsApp = async phone => {
|
|
|
|
|
console.log('正在重连:');
|
|
|
|
|
start();
|
|
|
|
|
} else {
|
|
|
|
|
waSocket.end(error => console.error('end.error: ', error));
|
|
|
|
|
waSocket.logout(msg => console.error('logout.msg: ', msg));
|
|
|
|
|
// waSocket.end(error => console.error('end.error: ', error));
|
|
|
|
|
// waSocket.logout(msg => console.error('logout.msg: ', msg));
|
|
|
|
|
console.log('Connection closed. You are logged out.');
|
|
|
|
|
|
|
|
|
|
waEmitter.emit('connection:close', {
|
|
|
|
|