mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-11-15 14:32:43 +01:00
Fix NeedsRelaybot check and relaybot command handling without arguments
This commit is contained in:
parent
0f4048a178
commit
691d2ea1b3
3 changed files with 7 additions and 3 deletions
|
@ -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:]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
2
user.go
2
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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue