mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
Properly handle noReplies() in nested commands.
This fix prevents the bot from replying 'Error: I tried to send you an empty message' when 'utilities ignore' is called from an Aka.
This commit is contained in:
parent
eaa5a5523e
commit
543edccd41
@ -206,6 +206,11 @@ class AkaChannelTestCase(ChannelPluginTestCase):
|
|||||||
self.assertResponse('a+ spam echo egg', 'The operation succeeded.')
|
self.assertResponse('a+ spam echo egg', 'The operation succeeded.')
|
||||||
self.assertResponse('spam', 'egg')
|
self.assertResponse('spam', 'egg')
|
||||||
|
|
||||||
|
def testIgnore(self):
|
||||||
|
self.assertResponse('aka add test ignore', 'The operation succeeded.')
|
||||||
|
self.assertNoResponse('test')
|
||||||
|
|
||||||
|
|
||||||
class AkaTestCase(PluginTestCase):
|
class AkaTestCase(PluginTestCase):
|
||||||
plugins = ('Aka', 'Alias', 'User', 'Utilities')
|
plugins = ('Aka', 'Alias', 'User', 'Utilities')
|
||||||
|
|
||||||
|
@ -49,11 +49,8 @@ class Utilities(callbacks.Plugin):
|
|||||||
Does nothing. Useful sometimes for sequencing commands when you don't
|
Does nothing. Useful sometimes for sequencing commands when you don't
|
||||||
care about their non-error return values.
|
care about their non-error return values.
|
||||||
"""
|
"""
|
||||||
if irc.nested:
|
msg.tag('ignored')
|
||||||
msg.tag('ignored')
|
irc.noReply()
|
||||||
# Need to call NestedCommandsIrcProxy.reply to continue evaluation
|
|
||||||
# of the remaining nested commands.
|
|
||||||
irc.reply('')
|
|
||||||
# Do be careful not to wrap this unless you do any('something').
|
# Do be careful not to wrap this unless you do any('something').
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
@ -37,6 +37,7 @@ class UtilitiesTestCase(PluginTestCase):
|
|||||||
def testIgnore(self):
|
def testIgnore(self):
|
||||||
self.assertNoResponse('utilities ignore foo bar baz', 1)
|
self.assertNoResponse('utilities ignore foo bar baz', 1)
|
||||||
self.assertError('utilities ignore [re m/foo bar]')
|
self.assertError('utilities ignore [re m/foo bar]')
|
||||||
|
self.assertResponse('echo [utilities ignore foobar] qux', 'qux')
|
||||||
|
|
||||||
def testSuccess(self):
|
def testSuccess(self):
|
||||||
self.assertNotError('success 1')
|
self.assertNotError('success 1')
|
||||||
|
@ -498,7 +498,7 @@ class RichReplyMethods(object):
|
|||||||
msg = self.reply(prefixer(s), **kwargs)
|
msg = self.reply(prefixer(s), **kwargs)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def noReply(self):
|
def noReply(self, msg=None):
|
||||||
self.repliedTo = True
|
self.repliedTo = True
|
||||||
|
|
||||||
def _error(self, s, Raise=False, **kwargs):
|
def _error(self, s, Raise=False, **kwargs):
|
||||||
@ -1011,6 +1011,16 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
self.args[self.counter] = s
|
self.args[self.counter] = s
|
||||||
self.evalArgs()
|
self.evalArgs()
|
||||||
|
|
||||||
|
def noReply(self, msg=None):
|
||||||
|
if msg is None:
|
||||||
|
msg = self.msg
|
||||||
|
if self.finalEvaled:
|
||||||
|
self.irc.noReply(msg=msg)
|
||||||
|
else:
|
||||||
|
self.args.pop(self.counter)
|
||||||
|
msg.tag('ignored', False)
|
||||||
|
self.evalArgs()
|
||||||
|
|
||||||
def replies(self, L, prefixer=None, joiner=None,
|
def replies(self, L, prefixer=None, joiner=None,
|
||||||
onlyPrefixFirst=False, to=None,
|
onlyPrefixFirst=False, to=None,
|
||||||
oneToOne=None, **kwargs):
|
oneToOne=None, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user