diff --git a/docker/golang.Dockerfile b/docker/golang.Dockerfile index 8e276b0..047fbb5 100644 --- a/docker/golang.Dockerfile +++ b/docker/golang.Dockerfile @@ -2,22 +2,22 @@ # STEP 1 build executable binary ############################ FROM golang:alpine AS builder -RUN apk update && apk add --no-cache vips-dev gcc musl-dev gcompat +RUN apk update && apk add --no-cache vips-dev gcc musl-dev gcompat ffmpeg WORKDIR /whatsapp COPY ./src . # Fetch dependencies. RUN go mod download # Install pkger -RUN go install github.com/gobuffalo/packr/v2/packr2@latest +RUN go install github.com/markbates/pkger/cmd/pkger@latest # Build the binary. -RUN go build -o /app/whatsapp +RUN pkger && go build -o /app/whatsapp ############################# ## STEP 2 build a smaller image ############################# FROM alpine -RUN apk update && apk add --no-cache vips-dev +RUN apk update && apk add --no-cache vips-dev ffmpeg WORKDIR /app # Copy compiled from builder. COPY --from=builder /app/whatsapp /app/whatsapp diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 722fa9f..672fecb 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: WhatsApp API MultiDevice - version: 2.2.1 + version: 2.3.0 description: This API is used for sending whatsapp via API servers: - url: http://localhost:3000 @@ -606,9 +606,6 @@ paths: caption: type: string example: selamat malam - view_once: - type: boolean - example: 'false' file: type: string format: binary @@ -689,3 +686,106 @@ paths: code: 500 message: you are not loggin results: null + /send/video: + post: + tags: + - send + summary: Send Video + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + phone: + type: integer + example: '6289685024091' + caption: + type: string + example: ini contoh caption video + view_once: + type: boolean + example: 'false' + video: + type: string + format: binary + type: + type: string + example: 'user' + description: 'user/group | default: user' + compress: + type: boolean + example: 'false' + responses: + '200': + description: OK + headers: + Date: + schema: + type: string + example: Fri, 11 Feb 2022 03:42:57 GMT + Content-Type: + schema: + type: string + example: application/json + Content-Length: + schema: + type: integer + example: '123' + content: + application/json: + schema: + type: object + example: + code: 200 + message: Success + results: + status: >- + Video sent to 6289685024091@s.whatsapp.net (server timestamp: 2022-05-17 14:39:29 +0700 WIB) + '400': + description: Bad Request + headers: + Date: + schema: + type: string + example: Fri, 11 Feb 2022 03:02:17 GMT + Content-Type: + schema: + type: string + example: application/json + Content-Length: + schema: + type: integer + example: '70' + content: + application/json: + schema: + type: object + example: + code: 400 + message: 'phone: cannot be blank.' + results: null + '500': + description: Internal Server Error + headers: + Date: + schema: + type: string + example: Fri, 11 Feb 2022 03:02:48 GMT + Content-Type: + schema: + type: string + example: application/json + Content-Length: + schema: + type: integer + example: '58' + content: + application/json: + schema: + type: object + example: + code: 500 + message: you are not loggin + results: null + diff --git a/readme.md b/readme.md index 265b160..2a4b1f1 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,7 @@ ### Feature - Send whatsapp via http API, [docs/openapi.yml](./docs/openapi.yaml) for more details - Compress image before send +- Compress video before send - Customizable port and debug mode - `--port 8000` - `--debug true` @@ -13,13 +14,16 @@ - Mac OS: - `brew install vips` + - `brew install ffmpeg` - `export CGO_CFLAGS_ALLOW="-Xpreprocessor"` - Linux: - `sudo apt update` - `sudo apt install libvips-dev` + - `sudo apt install ffmpeg` - Windows (not recomended, prefer using [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)): - install vips library, or you can check here https://www.libvips.org/install.html - - add to [environment variable](https://www.google.com/search?q=windows+add+to+environment+path) + - install ffmpeg, download [here](https://www.ffmpeg.org/download.html#build-windows) + - add to vips & ffmpg to [environment variable](https://www.google.com/search?q=windows+add+to+environment+path) ### How to use @@ -55,7 +59,7 @@ 7. open `http://localhost:3000` in browser ### Production Mode (docker) -- `docker run --publish 3000:3000 --restart=always aldinokemal2104/go-whatsapp-web-multidevice` +- `docker run --publish=3000:3000 --name=whatsapp --restart=always --detach aldinokemal2104/go-whatsapp-web-multidevice --autoreply="Dont't reply this message please"` ### Production Mode (binary) - download binary from [release](https://github.com/aldinokemal/go-whatsapp-web-multidevice/releases) @@ -65,19 +69,20 @@ You can fork or edit this source code ! ### Current API You can check [docs/openapi.yml](./docs/openapi.yaml) for detail API -| Feature | Menu | Method | URL | Payload | -|---------|-------------------------|--------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ✅ | Login | GET | /app/login | | -| ✅ | Logout | GET | /app/logout | | -| ✅ | Reconnect | GET | /app/reconnect | | -| ✅ | User Info | GET | /user/info |
| Param | Type | Type | Example |
|---|---|---|---|
| phone | string | querystring | 6289685024099 |
| Param | Type | Type | Example |
|---|---|---|---|
| phone | string | querystring | 6289685024099 |
| Param | Data Type | Type | Example |
|---|---|---|---|
| phone | string | form-data | 6289685024099 |
| message | string | form-data | Hello guys this is testing |
| type | string (user/group) | form-data | user |
| Param | Type | Type | Example |
|---|---|---|---|
| phone | string | form-data | 6289685024099 |
| caption | string | form-data | Hello guys this is caption |
| view_once | bool | form-data | false |
| image | binary | form-data | image/jpg,image/jpeg,image/png |
| type | string (user/group) | form-data | user |
| Param | Type | Type | Example |
|---|---|---|---|
| phone | string | form-data | 6289685024099 |
| file | binary | form-data | any (max: 10MB) |
| type | string (user/group) | form-data | user |
| Param | Type | Type | Example |
|---|---|---|---|
| phone | string | form-data | 6289685024099 |
| video | binary | form-data | mp4/avi/mkv |
| type | string (user/group) | form-data | user |