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) log.debug('IrcObjectProxy.__init__: %s' % args)
self.irc = irc self.irc = irc
self.msg = msg self.msg = msg
self.args = args[:] self.args = copy.deepcopy(args)
self.counter = 0 self.counter = 0
self.to = None self.to = None
self.action = False self.action = False
@ -397,7 +397,7 @@ class IrcObjectProxy:
def reply(self, msg, s, noLengthCheck=False, prefixName=True, def reply(self, msg, s, noLengthCheck=False, prefixName=True,
action=False, private=False, notice=False, to=None): 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: Keyword arguments:
noLengthCheck=False: True if the length shouldn't be checked noLengthCheck=False: True if the length shouldn't be checked
@ -467,6 +467,21 @@ class IrcObjectProxy:
self.args[self.counter] = s self.args[self.counter] = s
self.evalArgs() 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): def error(self, msg, s, private=False):
"""error(msg, text) -> replies to msg with an error message of text. """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): def testRepeat(self):
self.assertNotError('scheduler repeat repeater 5 echo foo bar baz') self.assertNotError('scheduler repeat repeater 5 echo foo bar baz')
self.assertNotError(' ') # replySuccess self.assertNotError(' ') # First response.
self.assertNoResponse(' ', 4) self.assertNoResponse(' ', 4)
self.assertResponse(' ', 'foo bar baz') self.assertResponse(' ', 'foo bar baz')
self.assertNoResponse(' ', 4) self.assertNoResponse(' ', 4)
@ -59,6 +59,16 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertNotError('scheduler remove repeater') self.assertNotError('scheduler remove repeater')
self.assertNoResponse(' ', 5) 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: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: