diff --git a/CHANGELOG.md b/CHANGELOG.md index a40c506b..f21a2245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v2.8.0 - POTENTIALLY BREAKING ambient message matching update +In most cases, if someone directs a message to the robot (issues a "command") in a channel, the message should go to the CatchAll if no command matches. Up to now, the default behavior was to match against `MessageMatchers`, even in the case of a command. Starting with v2.8.0, commands will no longer match against message matchers unless `AmbientMatchCommand` is set `true`. For most configurations this shouldn't be an issue, but this could break some configurations. Note that this has no effect in the case of direct messages to the robot, which are always considered commands; all direct messages to the robot can potentially match against `MessageMatchers`. + # v2.7.4 - Longer Memories Short-term memories really only came in to serious use with the OpenAI plugin, where 7 minutes just wasn't enough for expectations. Now Gopherbot robots have a 14-hour short-term memory. diff --git a/bot/dispatch.go b/bot/dispatch.go index 169463a6..937f0d50 100644 --- a/bot/dispatch.go +++ b/bot/dispatch.go @@ -55,6 +55,9 @@ func (w *worker) checkPluginMatchersAndRun(pipelineType pipelineType) (messageMa } matchers = plugin.CommandMatchers case plugMessage: + if w.isCommand && !w.directMsg && !plugin.AmbientMatchCommand { + continue + } if len(plugin.MessageMatchers) == 0 { continue } diff --git a/bot/taskconf.go b/bot/taskconf.go index 2bd64da7..dfa02579 100644 --- a/bot/taskconf.go +++ b/bot/taskconf.go @@ -326,7 +326,7 @@ LoadLoop: val = &intval case "Disabled": skip = true - case "AllowDirect", "DirectOnly", "DenyDirect", "AllChannels", "RequireAdmin", "AuthorizeAllCommands", "CatchAll", "MatchUnlisted", "Quiet": + case "AllowDirect", "AmbientMatchCommand", "DirectOnly", "DenyDirect", "AllChannels", "RequireAdmin", "AuthorizeAllCommands", "CatchAll", "MatchUnlisted", "Quiet": val = &boolval case "Channels", "ElevatedCommands", "ElevateImmediateCommands", "Users", "AuthorizedCommands", "AdminCommands", "ParameterSets": val = &sarrval @@ -459,6 +459,12 @@ LoadLoop: } else { job.Arguments = *(val.(*[]InputMatcher)) } + case "AmbientMatchCommand": + if isPlugin { + plugin.AmbientMatchCommand = *(val.(*bool)) + } else { + mismatch = true + } case "CatchAll": if isPlugin { plugin.CatchAll = *(val.(*bool)) diff --git a/bot/tasks.go b/bot/tasks.go index ae5eab12..2f09655e 100644 --- a/bot/tasks.go +++ b/bot/tasks.go @@ -192,6 +192,7 @@ type Plugin struct { Help []PluginHelp // All the keyword sets / help texts for this plugin CommandMatchers []InputMatcher // Input matchers for messages that need to be directed to the 'bot MessageMatchers []InputMatcher // Input matchers for messages the 'bot hears even when it's not being spoken to + AmbientMatchCommand bool // Whether message matchers should also match when isCommand is true CatchAll bool // Whenever the robot is spoken to, but no plugin matches, plugins with CatchAll=true get called with command="catchall" and argument= MatchUnlisted bool // Set to true if ambient messages matches should be checked for users not listed in the UserRoster *Task diff --git a/plugins/samples/hello.sh b/plugins/samples/hello.sh index 64d12377..f619d9d3 100755 --- a/plugins/samples/hello.sh +++ b/plugins/samples/hello.sh @@ -13,6 +13,7 @@ Help: CommandMatchers: - Regex: '(?i:hello world)' Command: "hello" +AmbientMatchCommand: true MessageMatchers: - Regex: 'hello robot' Command: "hello"