-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added onOrderStatusUpdate event
- Loading branch information
1 parent
76cd217
commit 149cd83
Showing
6 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
tokens | ||
package-lock.json | ||
debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Simple example to start the Wppconnect | ||
|
||
> Wppconnect is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp. | ||
## Maintainers | ||
|
||
Maintainers are needed, I cannot keep with all the updates by myself. If you are | ||
interested please open a Pull Request. | ||
|
||
## Contributing | ||
|
||
Pull requests are welcome. For major changes, please open an issue first to | ||
discuss what you would like to change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* This file is part of WPPConnect. | ||
* | ||
* WPPConnect is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* WPPConnect is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
const wppconnect = require('../../dist'); | ||
|
||
const froms = []; | ||
wppconnect | ||
.create() | ||
.then((client) => start(client)) | ||
.catch((erro) => { | ||
console.log(erro); | ||
}); | ||
|
||
function start(client) { | ||
client.onMessage(async (message) => { | ||
if (message.body === 'new order' && message.isGroupMsg === false) { | ||
const order = await client.sendOrderMessage(message.from, [ | ||
{ type: 'custom', name: 'Item with cost test', price: 120000, qnt: 2 }, | ||
]); | ||
froms.push(message.from); | ||
client.sendText( | ||
message.from, | ||
`Please, save your order id, and get order for test porpouse` | ||
); | ||
client.sendText(message.from, `${order.id}`); | ||
} | ||
if (message?.body?.includes('order id=') && message?.isGroupMsg === false) { | ||
const id = message?.body.split('=')[1]; | ||
const order = await client.getOrder(id); | ||
client.sendText(message.from, '```' + JSON.stringify(order) + '```'); | ||
} | ||
}); | ||
client.onOrderStatusUpdate((data) => { | ||
froms.forEach((from) => { | ||
client.sendText(from, '```' + JSON.stringify(data) + '```'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "wppconnect-functions", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters