From d241665208c22c6329f0829c0ac7c351614b0187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Fri, 27 Jul 2012 23:12:35 -0300 Subject: [PATCH] don't ignore extra words prefixed to the duration in @comment or @duration --- Bantracker/plugin.py | 7 +++++-- Bantracker/test.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) 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!*@*')