diff --git a/plugins/Observer.py b/plugins/Observer.py index 76996d461..bc8831409 100644 --- a/plugins/Observer.py +++ b/plugins/Observer.py @@ -136,7 +136,7 @@ class Observer(callbacks.Privmsg): m = r.search(msg.args[1]) if m is not None: command = observer.command() - groups = list(m.groups()) + groups = filter(None, list(m.groups())) groups.insert(0, m.group(0)) for (i, group) in enumerate(groups): command = command.replace('$%s' % i, group) diff --git a/test/test_Observer.py b/test/test_Observer.py index 2ca873073..33723ca4b 100644 --- a/test/test_Observer.py +++ b/test/test_Observer.py @@ -75,5 +75,10 @@ class ObserverTestCase(ChannelPluginTestCase): self.assertNotError('remove foo') self.assertRegexp('observer list', 'no relevant') + def testObserverWithEmptyGroup(self): + self.assertNotError('add foo m/foo(bar)?/i echo I saw foo.') + self.assertNotError('observer enable foo') + self.assertSnarfRegexp('foo', 'saw foo') + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: