This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from ookamiiixd/dev
Rewrite the entire thing
- Loading branch information
Showing
55 changed files
with
6,627 additions
and
7,089 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
HOST="localhost" | ||
PORT="3000" | ||
DATABASE_URL="mysql://root:12345@localhost:3306/baileys_api" | ||
RECONNECT_INTERVAL="5000" | ||
MAX_RECONNECT_RETRIES="5" | ||
SSE_MAX_QR_GENERATION="10" | ||
LOG_LEVEL="warn" |
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,2 @@ | ||
node_modules/ | ||
dist/ |
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,14 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], | ||
rules: { | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
'@typescript-eslint/no-unused-vars': 'error', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
custom: ['https://paypal.me/ookamiiixd', 'https://trakteer.id/ookamiiixd'] |
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
node_modules/ | ||
dist/ | ||
debug/ | ||
prisma/migrations/ | ||
.env | ||
*.tgz |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
sessions/ | ||
node_modules/ | ||
dist/ | ||
debug/ |
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Royhan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1,119 +1,62 @@ | ||
# Baileys API | ||
|
||
An implementation of [@adiwajshing/Baileys](https://github.com/adiwajshing/Baileys) as a simple RESTful API service with multiple device support. This project implements both **Legacy** (Normal WhatsApp Web) and **Beta Multi-Device** client so that you can choose and use one of them easily. | ||
An implementation of [@adiwajshing/Baileys](https://github.com/adiwajshing/Baileys) as a simple REST API with multiple device support | ||
|
||
## Requirements | ||
|
||
- **NodeJS** version **14.5.0** or higher. | ||
- **NodeJS** version **14.5.0** or higher | ||
|
||
## Installation | ||
|
||
1. Download or clone this repo. | ||
2. Enter to the project directory. | ||
3. Install the dependencies. | ||
1. Download or clone this repo. If you want to skip the build step, you can download the prebuilt one from the release page | ||
1. Enter to the project directory | ||
1. Install the dependencies | ||
1. Build the project using the `build` script. You can skip this part if you're using the prebuilt one from the release page | ||
|
||
## Setup | ||
|
||
1. Copy the `.env.example` file and rename it into `.env`, then update your [connection url](https://www.prisma.io/docs/reference/database-reference/connection-urls) in the `DATABASE_URL` field | ||
1. Run your [migration](https://www.prisma.io/docs/reference/api-reference/command-reference#prisma-migrate). Don't forget to always re-run your migration whenever there's a change on the `prisma/` directory | ||
|
||
## `.env` Configurations | ||
|
||
```env | ||
# Listening Host | ||
HOST=127.0.0.1 | ||
HOST="localhost" | ||
# Listening Port | ||
PORT=8000 | ||
PORT="3000" | ||
# Maximum Reconnect Attempts | ||
MAX_RETRIES=5 | ||
# Database Connection URL | ||
DATABASE_URL="mysql://root:12345@localhost:3306/baileys_api" | ||
# Reconnect Interval (in Milliseconds) | ||
RECONNECT_INTERVAL=5000 | ||
``` | ||
|
||
## Usage | ||
|
||
1. You can start the app by executing `npm run start` or `node .`. | ||
2. Now the endpoint should be available according to your environment variable configurations. Default is at `http://localhost:8000`. | ||
RECONNECT_INTERVAL="5000" | ||
Also check out the `examples` directory for the basic usage examples. | ||
|
||
## API Docs | ||
|
||
The API documentation is available online [here](https://documenter.getpostman.com/view/18988925/UVeNni36). You can also import the **Postman Collection File** `(postman_collection.json)` into your Postman App alternatively. | ||
# Maximum Reconnect Attempts | ||
MAX_RECONNECT_RETRIES="5" | ||
The server will respond in following JSON format: | ||
# Maximum SSE QR Generation Attempts | ||
SSE_MAX_QR_GENERATION="10" | ||
```javascript | ||
{ | ||
success: true|false, // bool | ||
message: "", // string | ||
data: {}|[] // object or array of object | ||
} | ||
# Pino Logger Level | ||
LOG_LEVEL="warn" | ||
``` | ||
|
||
## Sending Message | ||
|
||
All send message endpoints is now accept a JSON body, this gives you the ability to send any kind of supported message. You can pass any kind supported message into the `message` property. | ||
|
||
Here's some examples: | ||
|
||
```javascript | ||
// Send text message | ||
{ | ||
receiver: '628231xxxxx', | ||
message: { | ||
text: 'Hello there!' | ||
} | ||
} | ||
|
||
// Send image | ||
{ | ||
receiver: '628231xxxxx', | ||
message: { | ||
image: { | ||
url: 'https://example.com/logo.png' | ||
}, | ||
caption: 'My logo' | ||
} | ||
} | ||
|
||
// Send video | ||
{ | ||
receiver: '628231xxxxx', | ||
message: { | ||
video: { | ||
url: 'https://example.com/intro.mp4' | ||
}, | ||
caption: 'My intro' | ||
} | ||
} | ||
|
||
// Send document | ||
{ | ||
receiver: '628231xxxxx', | ||
message: { | ||
document: { | ||
url: 'https://example.com/presentation.pdf' | ||
}, | ||
mimetype: 'application/pdf', | ||
fileName: 'presentation-1.pdf' | ||
} | ||
} | ||
``` | ||
## Usage | ||
|
||
For more examples, check out Baileys's docs [here](https://github.com/adiwajshing/Baileys#sending-messages). | ||
1. Make sure to build the project first using the `build` script | ||
1. You can then start the app using the `start` script | ||
1. Now the endpoint should be available according to your environment variables configuration. Default is at `http://localhost:3000` | ||
|
||
## Known Issue | ||
## API Docs | ||
|
||
Currently there's no known issues. If you find any, please kindly open a new one. | ||
The API documentation is available online [here](https://documenter.getpostman.com/view/18988925/2s8Z73zWbg). You can also import the **Postman Collection File** `(postman_collection.json)` into your Postman App alternatively | ||
|
||
## Notes | ||
|
||
- The app only provide a very simple validation, you may want to implement your own. | ||
- When sending message, your `message` property will not be validated, so make sure you sent the right data! | ||
- There's no authentication, you may want to implement your own. | ||
- The **Beta Multi-Device** client use provided Baileys's `makeInMemoryStore` method which will store your data in memory and a json file, you may want to use a better data management. | ||
- Automatically reading incoming messages is now disabled by default. Uncomment `whatsapp.js:91-105` to enable this behaviour. | ||
- If you have problems when deploying on **CPanel** or any other similar hosting, transpiling your code into **CommonJS** should fix the problems. | ||
- There's no authentication, you may want to implement your own. I don't want to force anyone to use a specific authentication method, choose whatever you love | ||
|
||
## Notice | ||
|
||
This project is intended for learning purpose only, don't use it for spamming or any activities that's prohibited by **WhatsApp**. | ||
This project is intended for learning purpose only, don't use it for spamming or any activities that's prohibited by **WhatsApp** |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.