Fixed bugz0r with nested commands in Scheduler.repeat.

This commit is contained in:
Jeremy Fincher 2004-01-04 19:35:02 +00:00
parent 17c6e69d2f
commit 09dfe24573
2 changed files with 28 additions and 3 deletions

View File

@ -296,7 +296,7 @@ class IrcObjectProxy:
log.debug('IrcObjectProxy.__init__: %s' % args)
self.irc = irc
self.msg = msg
self.args = args[:]
self.args = copy.deepcopy(args)
self.counter = 0
self.to = None
self.action = False
@ -397,7 +397,7 @@ class IrcObjectProxy:
def reply(self, msg, s, noLengthCheck=False, prefixName=True,
action=False, private=False, notice=False, to=None):
"""reply(msg, text) -> replies to msg with text
"""reply(msg, s) -> replies to msg with s
Keyword arguments:
noLengthCheck=False: True if the length shouldn't be checked
@ -467,6 +467,21 @@ class IrcObjectProxy:
self.args[self.counter] = s
self.evalArgs()
def replySuccess(self, msg, s='', **kwargs):
if s:
s = '%s %s' % (conf.replySuccess, s)
else:
s = conf.replySuccess
self.reply(msg, s, **kwargs)
def replyNoCapability(self, msg, capability, s='', **kwargs):
if s:
s = '%s %s' % (conf.replyNoCapability % capability, s)
else:
s = conf.replyNoCapability % capability
self.reply(msg, s, **kwargs)
def error(self, msg, s, private=False):
"""error(msg, text) -> replies to msg with an error message of text.

View File

@ -51,7 +51,7 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
def testRepeat(self):
self.assertNotError('scheduler repeat repeater 5 echo foo bar baz')
self.assertNotError(' ') # replySuccess
self.assertNotError(' ') # First response.
self.assertNoResponse(' ', 4)
self.assertResponse(' ', 'foo bar baz')
self.assertNoResponse(' ', 4)
@ -59,6 +59,16 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertNotError('scheduler remove repeater')
self.assertNoResponse(' ', 5)
def testRepeatWorksWithNestedCommands(self):
self.assertNotError('scheduler repeat foo 5 "echo foo [echo bar]"')
self.assertNotError(' ') # First response.
self.assertNoResponse(' ', 4)
self.assertResponse(' ', 'foo bar')
self.assertNoResponse(' ', 4)
self.assertResponse(' ', 'foo bar')
self.assertNotError('scheduler remove foo')
self.assertNoResponse(' ', 5)
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: