-
Download Go modules
# Downloads go modules go mod tidy
-
Run
go run main.go
to show qr code for login on terminal -
Link device as explained on WhatsApp FAQ
A folder db/
will be automatically created containing sqlite db with credentials. No need to login over and over except logged out on main device. You can copy this folder to target machine and it still works
- Ensure
db/examplestore.db
exists and rundocker-compose up
- Open any chat (Personal/Group) where the logged in number is present
- Send media with caption and number should respond with sticker
WARNING: db/
folder on root will contain examplestore.db
which docker-compose expects to load as a volume. Do not create a public image using this folder or commit to version control as it can be used to impersonate you
The following flags are available
-log-level
: To switch between log verbosity betweenINFO
andDEBUG
-reply-to
: Set to true if bot should quote original messages with reply
|├── handler # Contains logic for running sticker procedure on images/video
| |___ handler.go
| |___ image.go
| |___ video.go
|
|├── LICENSE
|├── main.go # Login to WA client and sets up event handler
|└── README.md
- Initializes WA client (new credentials in db or uses existing)
- Sets up
eventHandler
to monitor all incoming events and passes WA client to media handler handler.Run() - Four possible messages trigger the core media handler
- One of either
Handler
gets initialized based on media type Handler
has some methods that get run- SetUp : set client to WA client, reply to option and create folders for media if not exist
- Validate: enforce some constraints on media size/length
- Handle: Downloads the raw media -> Converts media to webP (as WhatsApp stickers are wrappers around webp images) using the specified codec -> Uploads it to WA -> Return a sticker message
- SendResponse: Sends sticker to originating chat
- CleanUp: Remove raw and converted media from file system
- Media sizes/length enforced by code
- Some sticker results for videos are not animated (WebP size exceeds 1MB)
- Sometimes original media cannot be downloaded (especially for quoting older media messages with caption)
- reply-to flag causes iOS users to be incorrectly tagged
This project is opened under the MIT License which allows very broad use for both academic and commercial purposes
Library/Resource | Use |
---|---|
tulir/whatsmeow | whatsmeow is a Go library for the WhatsApp web multidevice API. |
ffmpeg | A complete cross platform solution to record, convert and stream video (and audio). |
cwebp | Compress an image file into WebP file |