Эх сурвалжийг харах

Fix NeedsRelaybot check and relaybot command handling without arguments

Tulir Asokan 5 жил өмнө
parent
commit
691d2ea1b3
3 өөрчлөгдсөн 7 нэмэгдсэн , 3 устгасан
  1. 4 0
      commands.go
  2. 2 2
      community.go
  3. 1 1
      user.go

+ 4 - 0
commands.go

@@ -152,6 +152,10 @@ func (handler *CommandHandler) CommandRelaybot(ce *CommandEvent) {
 		ce.Reply("Only admins can manage the relaybot")
 		ce.Reply("Only admins can manage the relaybot")
 	} else {
 	} else {
 		if ce.Command == "relaybot" {
 		if ce.Command == "relaybot" {
+			if len(ce.Args) == 0 {
+				ce.Reply("**Usage:** `relaybot <command>`")
+				return
+			}
 			ce.Command = strings.ToLower(ce.Args[0])
 			ce.Command = strings.ToLower(ce.Args[0])
 			ce.Args = ce.Args[1:]
 			ce.Args = ce.Args[1:]
 		}
 		}

+ 2 - 2
community.go

@@ -47,7 +47,7 @@ func (user *User) updateCommunityProfile() {
 }
 }
 
 
 func (user *User) createCommunity() {
 func (user *User) createCommunity() {
-	if !user.bridge.Config.Bridge.EnableCommunities() {
+	if user.IsRelaybot || !user.bridge.Config.Bridge.EnableCommunities() {
 		return
 		return
 	}
 	}
 
 
@@ -84,7 +84,7 @@ func (user *User) createCommunity() {
 }
 }
 
 
 func (user *User) addPortalToCommunity(portal *Portal) bool {
 func (user *User) addPortalToCommunity(portal *Portal) bool {
-	if len(user.CommunityID) == 0 || len(portal.MXID) == 0 {
+	if user.IsRelaybot || len(user.CommunityID) == 0 || len(portal.MXID) == 0 {
 		return false
 		return false
 	}
 	}
 	bot := user.bridge.Bot
 	bot := user.bridge.Bot

+ 1 - 1
user.go

@@ -781,5 +781,5 @@ func (user *User) HandleRawMessage(message *waProto.WebMessageInfo) {
 }
 }
 
 
 func (user *User) NeedsRelaybot(portal *Portal) bool {
 func (user *User) NeedsRelaybot(portal *Portal) bool {
-	return !user.HasSession() || user.IsInPortal(portal.Key.JID) || portal.IsPrivateChat()
+	return !user.HasSession() || (user.IsInPortal(portal.Key.JID) && (!portal.IsPrivateChat() || portal.Key.Receiver == user.JID))
 }
 }