Easy-Meow is a Go package that simplifies WhatsApp automation. Built on the powerful Whatsmeow backbone, it reduces boilerplate and makes WhatsApp bot development a breeze!
- 📉 Less code, more functionality
- 🚀 Built on the robust Whatsmeow framework
- 🛠 Simplified API for common WhatsApp operations
- 🐱 Purr-fectly easy to integrate into your projects
-
Diverse Message Types:
- Text: 📝 Send plain text messages effortlessly.
- Images: 📸 Share images with optional captions.
- Videos: 🎥 Send videos with captions.
- Audio: 🎵 Share audio files (including PTT – push-to-talk).
- Documents: 📄 Send documents with filenames and captions.
- Stickers: 🎉 Share your favorite stickers.
- GIFs: 🕺 Send animated GIFs with captions.
- Mentions: 👥 Tag users in messages.
- Phone Numbers: 📞 Send messages with clickable phone numbers.
- Reactions: 😍 Add emojis to react to messages.
-
Advanced Functionality:
- Replies: 🔁 Reply to specific messages.
- Edits: ✏️ Modify previously sent messages.
- Deletion: 🗑️ Delete messages you've sent.
- 📚 Comprehensive documentation
- 🧪 Example projects
- 🎨 Customizable themes for bot responses
- 🌐 Multi-language support
Want to be notified about updates? Star this repository and watch for the latest news!
To get started with Easy-Meow, follow these steps:
-
Initialize a new Go module:
go mod init <your-module-name>
-
Get the Easy-Meow package:
go get github.com/hacxk/easy-meow
-
Tidy up the module dependencies:
go mod tidy
-
Import and use Easy-Meow in your Go code:
Here's a beautifully formatted README.md
usage example for your Go program:
# WhatsApp Client Example
This example demonstrates how to use the custom WhatsApp client to handle events and send messages using the `easy-meow` package.
## Usage
### Import the Necessary Packages
```go
package main
import (
"context"
"fmt"
"log"
whatsappclient "github.com/hacxk/easy-meow/Client" // Importing your custom WhatsApp client package
"go.mau.fi/whatsmeow/types/events" // Importing events from the WhatsMeow library
)
// ### Define the Event Handler Function
// Define the event handler function
func myEventHandler(client *whatsappclient.WhatsAppClient, evt interface{}) {
// Type switch to handle different event types
switch v := evt.(type) {
case *events.Message:
// Extract message text from the message event (handle both conversation and extended messages)
var messageText string
if v.Message.Conversation != nil {
messageText = *v.Message.Conversation // Extract text from Conversation message
} else if v.Message.ExtendedTextMessage != nil {
messageText = *v.Message.ExtendedTextMessage.Text // Extract text from ExtendedTextMessage
}
// Print image message info (if available) and sender details
fmt.Print(v.Message.ImageMessage)
fmt.Printf("Received a message from %s (%s): %s\n", v.Info.Sender.String(), v.Info.Chat.String(), messageText)
// Check if the received message text is "hi"
if messageText == "hi" {
sock := client.GetClient() // Get the underlying client
// Send a reply message
_, err := sock.Reply(v, "Hello! 👋")
if err != nil {
log.Printf("Error sending reply: %v", err) // Log any error encountered while sending reply
}
}
case *events.Receipt:
// Handle receipt events
fmt.Printf("Received a receipt: %+v\n", v)
}
}
// ### Main Function
func main() {
ctx := context.Background() // Create a context for managing the connection
// Initialize the WhatsApp client with a store (database) file
client, err := whatsappclient.NewWhatsAppClient("examplestore.db")
if err != nil {
log.Fatalf("Failed to create client: %v", err) // Log and exit if client creation fails
}
// Connect the client
err = client.Connect(ctx)
if err != nil {
log.Fatalf("Failed to connect: %v", err) // Log and exit if connection fails
}
// Add the event handler to the client
client.AddEventHandler(func(evt interface{}) {
myEventHandler(client, evt) // Call the event handler with each received event
})
// Check for any errors in sending the message
if err != nil {
log.Printf("Failed to send message: %v", err) // Log any error encountered while sending a message
} else {
fmt.Println("Message sent successfully") // Confirm successful message sending
}
// Keep the program running
fmt.Println("Client is running. Press Ctrl+C to exit.") // Inform the user that the client is running
select {} // Block indefinitely to keep the program running
}
This project stands on the shoulders of giants:
- Whatsmeow - The powerful backbone of Easy-Meow.
MIT
Made with ❤️ by HACXK (Me Solo!)