mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
MessageParser: Show error when the action has a syntax error
Instead of being silent
This commit is contained in:
parent
6b72672a1e
commit
c23227cdc7
@ -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:
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user