fix bug when using @comment with a comma but bad duration syntax.

This commit is contained in:
Elián Hanisch 2012-07-27 21:08:25 -03:00
parent 02e5f2aa10
commit dfd9bdf633
2 changed files with 8 additions and 0 deletions

View File

@ -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:

View File

@ -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!*@*')