GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
feature: enhance mention logic (#188)
Aldino Kemalf8ac056e85e1
diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.ymlindex 4b6d0aee..8ecb8819 100644--- a/.github/workflows/release-linux.yml+++ b/.github/workflows/release-linux.yml@@ -18,7 +18,7 @@ jobs:- name: Golang Installationuses: actions/setup-go@v5with:- go-version: '1.21'+ go-version: '1.23'- name: Golang buildrun: |cd src && go build -o linux-amd64@@ -38,7 +38,7 @@ jobs:- name: Golang Installationuses: actions/setup-go@v5with:- go-version: '1.21'+ go-version: '1.23'- name: Golang buildrun: |cd src && go build -o linux-arm64diff --git a/.github/workflows/release-mac.yml b/.github/workflows/release-mac.ymlindex 9735f06d..6f471988 100644--- a/.github/workflows/release-mac.yml+++ b/.github/workflows/release-mac.yml@@ -18,7 +18,7 @@ jobs:- name: Golang Installationuses: actions/setup-go@v5with:- go-version: '1.21'+ go-version: '1.23'- name: Golang buildrun: |cd src && go build -o darwin-amd64diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.ymlindex bf04e4fc..820183e4 100644--- a/.github/workflows/release-windows.yml+++ b/.github/workflows/release-windows.yml@@ -18,7 +18,7 @@ jobs:- name: Golang Installationuses: actions/setup-go@v5with:- go-version: '1.21'+ go-version: '1.23'- name: Golang buildrun: |cd src && go build -o windows-amd64.exediff --git a/docker/golang.Dockerfile b/docker/golang.Dockerfileindex ea9c7af8..155605e7 100644--- a/docker/golang.Dockerfile+++ b/docker/golang.Dockerfile@@ -1,7 +1,7 @@############################# STEP 1 build executable binary############################-FROM golang:1.22.5-alpine3.20 AS builder+FROM golang:1.23-alpine3.20 AS builderRUN apk update && apk add --no-cache gcc musl-dev gcompatWORKDIR /whatsappCOPY ./src .diff --git a/readme.md b/readme.mdindex e336fbc8..a7244ec5 100644--- a/readme.md+++ b/readme.md@@ -167,3 +167,6 @@ You can fork or edit this source code !- Please do this if you have an error (invalid flag in pkg-config --cflags: -Xpreprocessor)`export CGO_CFLAGS_ALLOW="-Xpreprocessor"`++### Example+- [Verify HMAC Signature with NodeJS](https://pastebin.com/rYWuSi0T)\ No newline at end of filediff --git a/src/config/settings.go b/src/config/settings.goindex b072625e..eb33bb01 100644--- a/src/config/settings.go+++ b/src/config/settings.go@@ -5,7 +5,7 @@ import ()var (- AppVersion = "v4.17.0"+ AppVersion = "v4.18.0"AppPort = "3000"AppDebug = falseAppOs = "AldinoKemal"diff --git a/src/go.mod b/src/go.modindex 4c74d60a..504efcbc 100644--- a/src/go.mod+++ b/src/go.mod@@ -1,9 +1,11 @@module github.com/aldinokemal/go-whatsapp-web-multidevice-go 1.22+go 1.23++toolchain go1.23.1require (- github.com/PuerkitoBio/goquery v1.9.2+ github.com/PuerkitoBio/goquery v1.10.0github.com/disintegration/imaging v1.6.2github.com/dustin/go-humanize v1.0.1github.com/go-ozzo/ozzo-validation/v4 v4.3.0@@ -11,14 +13,14 @@ require (github.com/gofiber/template/html/v2 v2.1.2github.com/gofiber/websocket/v2 v2.2.1github.com/google/uuid v1.6.0- github.com/mattn/go-sqlite3 v1.14.22+ github.com/mattn/go-sqlite3 v1.14.23github.com/sirupsen/logrus v1.9.3github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686egithub.com/spf13/cobra v1.8.1github.com/stretchr/testify v1.9.0github.com/valyala/fasthttp v1.55.0go.mau.fi/libsignal v0.1.1- go.mau.fi/whatsmeow v0.0.0-20240821142752-3d63c6fcc1a7+ go.mau.fi/whatsmeow v0.0.0-20240911102933-bb3364aa3986google.golang.org/protobuf v1.34.2)@@ -46,10 +48,10 @@ require (github.com/valyala/bytebufferpool v1.0.0 // indirectgithub.com/valyala/tcplisten v1.0.0 // indirectgo.mau.fi/util v0.7.0 // indirect- golang.org/x/crypto v0.26.0 // indirect- golang.org/x/image v0.19.0 // indirect- golang.org/x/net v0.28.0 // indirect- golang.org/x/sys v0.24.0 // indirect+ golang.org/x/crypto v0.27.0 // indirect+ golang.org/x/image v0.20.0 // indirect+ golang.org/x/net v0.29.0 // indirect+ golang.org/x/sys v0.25.0 // indirectgolang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirectgopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirectgopkg.in/yaml.v3 v3.0.1 // indirectdiff --git a/src/go.sum b/src/go.sumindex c886eb6b..0074d26e 100644--- a/src/go.sum+++ b/src/go.sum@@ -2,6 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=+github.com/PuerkitoBio/goquery v1.10.0 h1:6fiXdLuUvYs2OJSvNRqlNPoBm6YABE226xrbavY5Wv4=+github.com/PuerkitoBio/goquery v1.10.0/go.mod h1:TjZZl68Q3eGHNBA8CWaxAN7rOU1EbDz3CWuolcO5Yu4=github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=@@ -58,6 +60,8 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6Tgithub.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=+github.com/mattn/go-sqlite3 v1.14.23 h1:gbShiuAP1W5j9UOksQ06aiiqPMxYecovVGwmTxWtuw0=+github.com/mattn/go-sqlite3 v1.14.23/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=@@ -96,13 +100,19 @@ go.mau.fi/util v0.7.0 h1:l31z+ivrSQw+cv/9eFebEqtQW2zhxivGypn+JT0h/ws=go.mau.fi/util v0.7.0/go.mod h1:bWYreIoTULL/UiRbZdfddPh7uWDFW5yX4YCv5FB0eE0=go.mau.fi/whatsmeow v0.0.0-20240821142752-3d63c6fcc1a7 h1:Aa4uov0rM0SQQ7Fc/TZZpmQEGksie2SVTv/UuCJwViI=go.mau.fi/whatsmeow v0.0.0-20240821142752-3d63c6fcc1a7/go.mod h1:BhHKalSq0qNtSCuGIUIvoJyU5KbT4a7k8DQ5yw1Ssk4=+go.mau.fi/whatsmeow v0.0.0-20240911102933-bb3364aa3986 h1:7X+3826qoRBHPCtxY89tqMcYEsi9+OuWE6hHZfRc0qI=+go.mau.fi/whatsmeow v0.0.0-20240911102933-bb3364aa3986/go.mod h1:BhHKalSq0qNtSCuGIUIvoJyU5KbT4a7k8DQ5yw1Ssk4=golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=+golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=+golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=+golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw=+golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM=golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=@@ -112,6 +122,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=+golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=+golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=@@ -128,6 +140,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=+golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=+golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=diff --git a/src/pkg/utils/general.go b/src/pkg/utils/general.goindex f530c043..af43d310 100644--- a/src/pkg/utils/general.go+++ b/src/pkg/utils/general.go@@ -7,6 +7,7 @@ import ("net/http""os""path/filepath"+ "regexp""strconv""strings""time"@@ -95,13 +96,16 @@ func GetMetaDataFromURL(url string) (meta Metadata) {// ContainsMention is checking if message contains mention, then return only mention without @func ContainsMention(message string) []string {- var mentions []string- words := strings.Fields(message)- for _, word := range words {- if strings.HasPrefix(word, "@") {- mentions = append(mentions, word[1:])+ // Regular expression to find all phone numbers after the @ symbol+ re := regexp.MustCompile(`@(\d+)`)+ matches := re.FindAllStringSubmatch(message, -1)++ var phoneNumbers []string+ // Loop through the matches and extract the phone numbers+ for _, match := range matches {+ if len(match) > 1 {+ phoneNumbers = append(phoneNumbers, match[1])}}-- return mentions+ return phoneNumbers}diff --git a/src/pkg/utils/general_test.go b/src/pkg/utils/general_test.gonew file mode 100644index 00000000..6c80a29d--- /dev/null+++ b/src/pkg/utils/general_test.go@@ -0,0 +1,40 @@+package utils_test++import (+ "github.com/aldinokemal/go-whatsapp-web-multidevice/pkg/utils"+ "github.com/stretchr/testify/assert"+ "testing"+)++func TestContainsMention(t *testing.T) {+ type args struct {+ message string+ }+ tests := []struct {+ name string+ args args+ want []string+ }{+ {+ name: "should success get phone when @ with space",+ args: args{message: "welcome @6289123 ."},+ want: []string{"6289123"},+ },+ {+ name: "should success get phone without suffix space",+ args: args{message: "welcome @6289123."},+ want: []string{"6289123"},+ },+ {+ name: "should success get phone without prefix space",+ args: args{message: "welcome@6289123.@hello:@62891823"},+ want: []string{"6289123", "62891823"},+ },+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ got := utils.ContainsMention(tt.args.message)+ assert.Equal(t, tt.want, got)+ })+ }+}