Skip to content

Commit

Permalink
Fixes an issue were CC with regex or contains trigger would trigger m…
Browse files Browse the repository at this point in the history
…ultiple times (#1777)

* fix ccs triggering twice for forwards

* fix ccs triggering twice for forwards

---------

Co-authored-by: Ashish <ashishjh-bst@users.noreply.github.com>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Nov 28, 2024
1 parent a3a2954 commit 03ce0cf
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions customcommands/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,17 +992,12 @@ func findMessageTriggerCustomCommands(ctx context.Context, cs *dstate.ChannelSta
if cmd.Disabled || !CmdRunsInChannel(cmd, common.ChannelOrThreadParentID(cs)) || !CmdRunsForUser(cmd, ms) || cmd.R.Group != nil && cmd.R.Group.Disabled {
continue
}
content := msg.Content
if cmd.TriggerType == int(CommandTriggerContains) || cmd.TriggerType == int(CommandTriggerRegex) {
for _, content := range msg.GetMessageContents() {
if didMatch, stripped, args := CheckMatch(prefix, cmd, content); didMatch {
matched = append(matched, &TriggeredCC{
CC: cmd,
Args: args,
Stripped: stripped,
})
}
}
} else if didMatch, stripped, args := CheckMatch(prefix, cmd, msg.Content); didMatch {
//for contains and regex match, we need to look at the content of the forwarded message too.
content = strings.Join(msg.GetMessageContents(), " ")
}
if didMatch, stripped, args := CheckMatch(prefix, cmd, content); didMatch {
matched = append(matched, &TriggeredCC{
CC: cmd,
Args: args,
Expand Down

0 comments on commit 03ce0cf

Please sign in to comment.