diff --git a/Bantracker/plugin.py b/Bantracker/plugin.py index f2d4408..94ab270 100644 --- a/Bantracker/plugin.py +++ b/Bantracker/plugin.py @@ -113,6 +113,9 @@ def readTimeDelta(s): digit = string = number = None seconds = 0 for c in s: + if c == ' ': + continue + if c.isdigit(): if string is None: # start @@ -132,7 +135,7 @@ def readTimeDelta(s): else: if digit is None: # need a number first - continue + raise ValueError(s) if digit is True: digit = False # completed a number @@ -1544,7 +1547,7 @@ class Bantracker(callbacks.Plugin): nick = msg.nick duration, banset = None, [] if kickmsg and ',' in kickmsg: - s = kickmsg[kickmsg.rfind(','):] + s = kickmsg[kickmsg.rfind(',') + 1:] try: duration = readTimeDelta(s) except ValueError: diff --git a/Bantracker/test.py b/Bantracker/test.py index 1f63982..a2dfaa4 100644 --- a/Bantracker/test.py +++ b/Bantracker/test.py @@ -136,6 +136,8 @@ class BantrackerTestCase(ChannelPluginTestCase): self.feedBan('nick', mode='k') self.assertResponse('comment 2 this is a kick, 2week', 'The operation succeeded.') + self.assertResponse('comment 1 not a valid, duration 2', + 'The operation succeeded.') def testMultiComment(self): self.feedBan('asd!*@*')