Browse Source
feature: enhance mention logic (#188)
feature: enhance mention logic (#188)
* feat: update dependencies and improve mention detection - upgrade Go version in go.mod to 1.23 and specify toolchain - update several dependencies to their latest versions - change mention detection to use regular expressions for better accuracy - add tests for mention detection to verify correctness * feat: upgrade versionpull/202/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 84 additions and 21 deletions
-
4.github/workflows/release-linux.yml
-
2.github/workflows/release-mac.yml
-
2.github/workflows/release-windows.yml
-
2docker/golang.Dockerfile
-
3readme.md
-
2src/config/settings.go
-
18src/go.mod
-
14src/go.sum
-
18src/pkg/utils/general.go
-
40src/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) |
|||
}) |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue