浏览代码

Reimplement invite-link command

Tulir Asokan 3 年之前
父节点
当前提交
1f91eacc10
共有 3 个文件被更改,包括 9 次插入14 次删除
  1. 6 11
      commands.go
  2. 1 1
      go.mod
  3. 2 2
      go.sum

+ 6 - 11
commands.go

@@ -228,20 +228,15 @@ const cmdInviteLinkHelp = `invite-link - Get an invite link to the current group
 func (handler *CommandHandler) CommandInviteLink(ce *CommandEvent) {
 func (handler *CommandHandler) CommandInviteLink(ce *CommandEvent) {
 	if ce.Portal == nil {
 	if ce.Portal == nil {
 		ce.Reply("Not a portal room")
 		ce.Reply("Not a portal room")
-		return
 	} else if ce.Portal.IsPrivateChat() {
 	} else if ce.Portal.IsPrivateChat() {
 		ce.Reply("Can't get invite link to private chat")
 		ce.Reply("Can't get invite link to private chat")
-		return
+	} else if ce.Portal.IsBroadcastList() {
+		ce.Reply("Can't get invite link to broadcast list")
+	} else if link, err := ce.User.Client.GetGroupInviteLink(ce.Portal.Key.JID); err != nil {
+		ce.Reply("Failed to get invite link: %v", err)
+	} else {
+		ce.Reply(link)
 	}
 	}
-
-	ce.Reply("Not yet implemented")
-	// TODO reimplement
-	//link, err := ce.User.Conn.GroupInviteLink(ce.Portal.Key.JID)
-	//if err != nil {
-	//	ce.Reply("Failed to get invite link: %v", err)
-	//	return
-	//}
-	//ce.Reply("%s%s", inviteLinkPrefix, link)
 }
 }
 
 
 const cmdJoinHelp = `join <invite link> - Join a group chat with an invite link.`
 const cmdJoinHelp = `join <invite link> - Join a group chat with an invite link.`

+ 1 - 1
go.mod

@@ -8,7 +8,7 @@ require (
 	github.com/mattn/go-sqlite3 v1.14.9
 	github.com/mattn/go-sqlite3 v1.14.9
 	github.com/prometheus/client_golang v1.11.0
 	github.com/prometheus/client_golang v1.11.0
 	github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
 	github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
-	go.mau.fi/whatsmeow v0.0.0-20211031112955-d9ede8b4ef4b
+	go.mau.fi/whatsmeow v0.0.0-20211031131127-03a69c3e343b
 	golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
 	golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
 	google.golang.org/protobuf v1.27.1
 	google.golang.org/protobuf v1.27.1
 	gopkg.in/yaml.v2 v2.4.0
 	gopkg.in/yaml.v2 v2.4.0

+ 2 - 2
go.sum

@@ -139,8 +139,8 @@ github.com/tidwall/sjson v1.2.3 h1:5+deguEhHSEjmuICXZ21uSSsXotWMA0orU783+Z7Cp8=
 github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs=
 github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs=
 go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ=
 go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ=
 go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos=
 go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos=
-go.mau.fi/whatsmeow v0.0.0-20211031112955-d9ede8b4ef4b h1:c9LwexDAVDsLNXcD4Vog5Y624sihnomf9XJl8ewtBl4=
-go.mau.fi/whatsmeow v0.0.0-20211031112955-d9ede8b4ef4b/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI=
+go.mau.fi/whatsmeow v0.0.0-20211031131127-03a69c3e343b h1:GvVBHYS4iBduhXtsPsnqJtrt8BP1OqYp6OdZqYtt/xY=
+go.mau.fi/whatsmeow v0.0.0-20211031131127-03a69c3e343b/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI=
 golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=