From dfd9bdf6331c03f459489b27d4b304b7f57873c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eli=C3=A1n=20Hanisch?= Date: Fri, 27 Jul 2012 21:08:25 -0300 Subject: [PATCH] fix bug when using @comment with a comma but bad duration syntax. --- Bantracker/plugin.py | 6 ++++++ Bantracker/test.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/Bantracker/plugin.py b/Bantracker/plugin.py index c93efd1..39922e5 100644 --- a/Bantracker/plugin.py +++ b/Bantracker/plugin.py @@ -107,6 +107,9 @@ timeUnits = FuzzyDict({ def readTimeDelta(s): """convert a string like "2 days" or "1h2d3w" into seconds""" # split number and words + if not s: + raise ValueError(s) + digit = string = number = None seconds = 0 for c in s: @@ -137,6 +140,9 @@ def readTimeDelta(s): string += c # check last string + if string is None: + raise ValueError(s) + if string.isdigit(): seconds += int(string) else: diff --git a/Bantracker/test.py b/Bantracker/test.py index 16c3aba..01206d9 100644 --- a/Bantracker/test.py +++ b/Bantracker/test.py @@ -130,6 +130,8 @@ class BantrackerTestCase(ChannelPluginTestCase): self.assertResponse('comment 1', 'No comments recorded for ban 1') self.assertResponse('comment 1 this is a test', 'The operation succeeded.') self.assertRegexp('comment 1', 'test: this is a test$') + self.assertResponse('comment 1 this is a test, another test', + 'The operation succeeded.') def testMultiComment(self): self.feedBan('asd!*@*')