From f7fd01221840108831b40e316d52e2eb159ede8c Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 20 Sep 2018 23:45:58 +0300 Subject: [PATCH] Use fallbackless body when matching passive commands --- matrix/commands.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/matrix/commands.go b/matrix/commands.go index 9a23687..5bc264a 100644 --- a/matrix/commands.go +++ b/matrix/commands.go @@ -162,9 +162,17 @@ func (pc *ParsedCommand) MatchActive(evt *gomatrix.Event) bool { } func (pc *ParsedCommand) MatchPassive(evt *gomatrix.Event) bool { - matchAgainst, ok := deepGet(evt.Content.Raw, pc.MatchAgainst).(string) - if !ok { + matchAgainst := evt.Content.Body + switch pc.MatchAgainst { + case maubot.MatchAgainstBody: matchAgainst = evt.Content.Body + case "formatted_body": + matchAgainst = evt.Content.FormattedBody + default: + matchAgainstDirect, ok := deepGet(evt.Content.Raw, pc.MatchAgainst).(string) + if ok { + matchAgainst = matchAgainstDirect + } } if pc.MatchesEvent != nil && !maubot.JSONLeftEquals(pc.MatchesEvent, evt) {