From 1aa615850b2016fada48024187a7a9285fad8285 Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 4 Jan 2005 16:57:57 +0000 Subject: [PATCH] Fix a bug that occurs when an optional group is not matched. --- plugins/Observer.py | 2 +- test/test_Observer.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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: