diff --git a/README.md b/README.md index c9a359c..a6c3c76 100644 --- a/README.md +++ b/README.md @@ -62,17 +62,16 @@ docker-compose pull && docker-compose up | Actions | Status | Sessions | Status | Callbacks | Status | | ----------------------------| ------| ----------------------------------------| ------| ----------------------------------------------| ------| | Send Image Message | ✅ | Initiate session | ✅ | Callback QR code | ✅ | -| Send Video Message | ✅ | Terminate session | ✅ | Callback new message | ✅ | +| Send Video Message(requires Google Chrome) | ✅ | Terminate session | ✅ | Callback new message | ✅ | | Send Audio Message | ✅ | Terminate inactive sessions | ✅ | Callback status change | ✅ | | Send Document Message | ✅ | Terminate all sessions | ✅ | Callback message media attachment | ✅ | -| Send File URL | ✅ | Healthcheck | ✅ | | | -| Send Button Message | ✅ | Local test callback | | | | -| Send Contact Message | ✅ | | | | | -| Send List Message | ✅ | | | | | +| Send File URL | ✅ | Restart session | ✅ | | | +| Send Contact Message | ✅ | Get session status | ✅ | | | +| Send Poll Message | ✅ | Health Check | ✅ | | | +| Edit Message | ✅ | | | | | | Set Status | ✅ | | | | | -| Send Button With Media | ✅ | | | | | | Is On Whatsapp? | ✅ | | | | | -| Download Profile Pic | ✅ | | | | | +| Download Profile Picture | ✅ | | | | | | User Status | ✅ | | | | | | Block/Unblock User | ✅ | | | | | | Update Profile Picture | ✅ | | | | | @@ -88,15 +87,15 @@ docker-compose pull && docker-compose up | Update Group Subject | ✅ | | | | | | Update Group Description | ✅ | | | | | -3. Handle multiple client sessions (session data saved locally), identified by unique id +1. Handle multiple client sessions (session data saved locally), identified by unique id -4. All endpoints may be secured by a global API key +2. All endpoints may be secured by a global API key -5. On server start, all existing sessions are restored +3. On server start, all existing sessions are restored -6. Set messages automatically as read +4. Set messages automatically as read -7. Disable any of the callbacks +5. Disable any of the callbacks ## Run Locally diff --git a/src/controllers/clientController.js b/src/controllers/clientController.js index 4ad7a9a..7856b81 100644 --- a/src/controllers/clientController.js +++ b/src/controllers/clientController.js @@ -1,4 +1,4 @@ -const { MessageMedia, Location, Buttons, List, Poll } = require('whatsapp-web.js') +const { MessageMedia, Location, Poll } = require('whatsapp-web.js') const { sessions } = require('../sessions') const { sendErrorResponse } = require('../utils') @@ -30,11 +30,11 @@ const sendMessage = async (req, res) => { properties: { chatId: { type: 'string', - description: 'The Chat id which contains the message (Group or Individual)', + description: 'The chat id which contains the message (Group or Individual)', }, contentType: { type: 'string', - description: 'The type of message content, must be one of the following: string, MessageMedia, MessageMediaFromURL, Location, Contact, Poll, Buttons, or List', + description: 'The type of message content, must be one of the following: string, MessageMedia, MessageMediaFromURL, Location, Contact or Poll', }, content: { type: 'object', @@ -51,10 +51,6 @@ const sendMessage = async (req, res) => { MessageMedia: { value: { chatId: '6281288888888@c.us', contentType: 'MessageMedia', content: { mimetype: 'image/jpeg', data: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', filename: 'image.jpg' } } }, MessageMediaFromURL: { value: { chatId: '6281288888888@c.us', contentType: 'MessageMediaFromURL', content: 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=Example' } }, Location: { value: { chatId: '6281288888888@c.us', contentType: 'Location', content: { latitude: -6.2, longitude: 106.8, description: 'Jakarta' } } }, - Buttons: { value: { chatId: '6281288888888@c.us', contentType: 'Buttons', content: { body: 'Hello World!', buttons: [{ body: 'button 1' }], title: 'Hello World!', footer: 'Hello World!' } } }, - List: { - value: { chatId: '6281288888888@c.us', contentType: 'List', content: { body: 'Hello World!', buttonText: 'Hello World!', sections: [{ title: 'sectionTitle', rows: [{ id: 'customId', title: 'ListItem2', description: 'desc' }, { title: 'ListItem2' }] }], title: 'Hello World!', footer: 'Hello World!' } } - }, Contact: { value: { chatId: '6281288888888@c.us', contentType: 'Contact', content: { contactId: '6281288888889@c.us' } } }, @@ -97,16 +93,6 @@ const sendMessage = async (req, res) => { messageOut = await client.sendMessage(chatId, location, options) break } - case 'Buttons': { - const buttons = new Buttons(content.body, content.buttons, content.title, content.footer) - messageOut = await client.sendMessage(chatId, buttons, options) - break - } - case 'List': { - const list = new List(content.body, content.buttonText, content.sections, content.title, content.footer) - messageOut = await client.sendMessage(chatId, list, options) - break - } case 'Contact': { const contactId = content.contactId.endsWith('@c.us') ? content.contactId : `${content.contactId}@c.us` const contact = await client.getContactById(contactId) @@ -121,7 +107,6 @@ const sendMessage = async (req, res) => { default: return sendErrorResponse(res, 400, 'contentType invalid, must be string, MessageMedia, MessageMediaFromURL, Location, Buttons, List, Contact or Poll') } - res.json({ success: true, message: messageOut }) } catch (error) { console.log(error) diff --git a/src/controllers/messageController.js b/src/controllers/messageController.js index e216b7f..346e376 100644 --- a/src/controllers/messageController.js +++ b/src/controllers/messageController.js @@ -1,4 +1,4 @@ -const { MessageMedia, Location, Buttons, List, Poll } = require('whatsapp-web.js') +const { MessageMedia, Location, Poll } = require('whatsapp-web.js') const { sessions } = require('../sessions') const { sendErrorResponse } = require('../utils') @@ -418,7 +418,7 @@ const reply = async (req, res) => { }, contentType: { type: 'string', - description: 'The type of message content, must be one of the following: string, MessageMedia, MessageMediaFromURL, Location, Contact, Poll, Buttons, or List', + description: 'The type of message content, must be one of the following: string, MessageMedia, MessageMediaFromURL, Location, Contact or Poll', }, content: { type: 'object', @@ -465,14 +465,6 @@ const reply = async (req, res) => { contentMessage = new Location(content.latitude, content.longitude, content.description) break } - case 'Buttons': { - contentMessage = new Buttons(content.body, content.buttons, content.title, content.footer) - break - } - case 'List': { - contentMessage = new List(content.body, content.buttonText, content.sections, content.title, content.footer) - break - } case 'Contact': { const contactId = content.contactId.endsWith('@c.us') ? content.contactId : `${content.contactId}@c.us` contentMessage = await client.getContactById(contactId)