Add support for wa.me/qr links in resolve command. Fixes #556

This commit is contained in:
Tulir Asokan 2022-09-28 14:45:09 +03:00
parent 0e298bb88b
commit 6c517eaaeb
3 changed files with 15 additions and 4 deletions

View File

@ -177,7 +177,7 @@ var cmdResolveLink = &commands.FullHandler{
Help: commands.HelpMeta{
Section: HelpSectionInvites,
Description: "Resolve a WhatsApp group invite or business message link.",
Args: "<_group or message link_>",
Args: "<_group, contact, or message link_>",
},
RequiresLogin: true,
}
@ -209,6 +209,17 @@ func fnResolveLink(ce *WrappedCommandEvent) {
message = fmt.Sprintf(" The following prefilled message is attached:\n\n%s", strings.Join(parts, "\n"))
}
ce.Reply("That link points at %s (+%s).%s", target.PushName, target.JID.User, message)
} else if strings.HasPrefix(ce.Args[0], whatsmeow.ContactQRLinkPrefix) || strings.HasPrefix(ce.Args[0], whatsmeow.ContactQRLinkDirectPrefix) {
target, err := ce.User.Client.ResolveContactQRLink(ce.Args[0])
if err != nil {
ce.Reply("Failed to get contact info: %v", err)
return
}
if target.PushName != "" {
ce.Reply("That link points at %s (+%s)", target.PushName, target.JID.User)
} else {
ce.Reply("That link points at +%s", target.JID.User)
}
} else {
ce.Reply("That doesn't look like a group invite link nor a business message link.")
}

2
go.mod
View File

@ -11,7 +11,7 @@ require (
github.com/prometheus/client_golang v1.13.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.3
go.mau.fi/whatsmeow v0.0.0-20220912085258-5c8577b8ac6f
go.mau.fi/whatsmeow v0.0.0-20220928114434-ebe489ef67ef
golang.org/x/image v0.0.0-20220722155232-062f8c9fd539
golang.org/x/net v0.0.0-20220812174116-3211cb980234
google.golang.org/protobuf v1.28.1

4
go.sum
View File

@ -63,8 +63,8 @@ github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mau.fi/libsignal v0.0.0-20220628090436-4d18b66b087e h1:ByHDg+D+dMIGuBA2n+1xOUf4xr3FJFYg8yxl06s1YBE=
go.mau.fi/libsignal v0.0.0-20220628090436-4d18b66b087e/go.mod h1:RCdzkTWSJv0AKGqurzPXJsEGIVMuQps3E/h7CMUPous=
go.mau.fi/whatsmeow v0.0.0-20220912085258-5c8577b8ac6f h1:tyuzYQcAwx+cwnnJw2i+utO/xWSj8RutT9Najc+DgOk=
go.mau.fi/whatsmeow v0.0.0-20220912085258-5c8577b8ac6f/go.mod h1:hsjqq2xLuoFew8vbsDCJcGf5EbXCRcR/yoQ+87w6m3k=
go.mau.fi/whatsmeow v0.0.0-20220928114434-ebe489ef67ef h1:32Ki56jfx+tg8B8Qla/przLXJchD4Y2NtlggA1oG+cs=
go.mau.fi/whatsmeow v0.0.0-20220928114434-ebe489ef67ef/go.mod h1:hsjqq2xLuoFew8vbsDCJcGf5EbXCRcR/yoQ+87w6m3k=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 h1:/eM0PCrQI2xd471rI+snWuu251/+/jpBpZqir2mPdnU=