1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-01-12 01:22:30 +02:00
notify/service/whatsapp
2021-02-15 10:56:59 +05:30
..
doc.go feat(service): Add WhatsApp service 2021-02-15 10:56:59 +05:30
mock_whatsappClient.go feat(service): Add WhatsApp service 2021-02-15 10:56:59 +05:30
README.md feat(service): Add WhatsApp service 2021-02-15 10:56:59 +05:30
whatsapp_test.go feat(service): Add WhatsApp service 2021-02-15 10:56:59 +05:30
whatsapp.go feat(service): Add WhatsApp service 2021-02-15 10:56:59 +05:30

WhatsApp

go.dev reference

Prerequisites

You will need a registered WhatsApp phone number to be used as source for sending WhatsApp messages.

Usage

In the current implementation, authentication requires scanning QR code from terminal using a registered WhatsApp device. Please refer Login (go-whatsapp) and sigalor/whatsapp-web-reveng for more details.

package main

import (
        "log"

        "github.com/nikoksr/notify"
        "github.com/nikoksr/notify/service/whatsapp"
)

func main() {
        whatsappSvc, err := whatsapp.New()
        if err != nil {
                log.Fatalf("whatsapp.New() failed: %s", err.Error())
        }

        whatsappSvc.AddReceivers("Contact1")

        notifier := notify.New()
        notifier.UseServices(whatsappSvc)

        err = notifier.Send("subject", "message")
        if err != nil {
                log.Fatalf("notifier.Send() failed: %s", err.Error())
        }

        log.Println("notification sent")
}