diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index 604378e36..8e043db70 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -129,8 +129,13 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): def _runCommandFunction(self, irc, msg, command): """Run a command from message, as if command was sent over IRC.""" - tokens = callbacks.tokenize(command, - channel=msg.channel, network=irc.network) + try: + tokens = callbacks.tokenize(command, + channel=msg.channel, network=irc.network) + except SyntaxError as e: + # Emulate what callbacks.py does + self.log.debug('Error return: %s', utils.exnToString(e)) + irc.error(str(e)) try: self.Proxy(irc.irc, msg, tokens) except Exception as e: diff --git a/plugins/MessageParser/test.py b/plugins/MessageParser/test.py index 61c77a910..f08abde49 100644 --- a/plugins/MessageParser/test.py +++ b/plugins/MessageParser/test.py @@ -85,6 +85,11 @@ class MessageParserTestCase(ChannelPluginTestCase): self.assertResponse(' ', '$1') self.assertNotError('messageparser remove "this( .+)? a(.*)"') + def testSyntaxError(self): + self.assertNotError(r'messageparser add "test" "echo foo \" bar"') + self.feedMsg('test') + self.assertResponse(' ', 'Error: No closing quotation') + def testShow(self): self.assertNotError('messageparser add "stuff" "echo i saw some stuff"') self.assertRegexp('messageparser show "nostuff"', 'there is no such regexp trigger')