Fix a bug that occurs when an optional group is not matched.

This commit is contained in:
James Vega 2005-01-04 16:57:57 +00:00
parent 0d954c9354
commit 1aa615850b
2 changed files with 6 additions and 1 deletions

View File

@ -136,7 +136,7 @@ class Observer(callbacks.Privmsg):
m = r.search(msg.args[1]) m = r.search(msg.args[1])
if m is not None: if m is not None:
command = observer.command() command = observer.command()
groups = list(m.groups()) groups = filter(None, list(m.groups()))
groups.insert(0, m.group(0)) groups.insert(0, m.group(0))
for (i, group) in enumerate(groups): for (i, group) in enumerate(groups):
command = command.replace('$%s' % i, group) command = command.replace('$%s' % i, group)

View File

@ -75,5 +75,10 @@ class ObserverTestCase(ChannelPluginTestCase):
self.assertNotError('remove foo') self.assertNotError('remove foo')
self.assertRegexp('observer list', 'no relevant') 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: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: