mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
Fix a bug that occurs when an optional group is not matched.
This commit is contained in:
parent
0d954c9354
commit
1aa615850b
@ -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)
|
||||||
|
@ -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:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user