fix bug when using @comment with a comma but bad duration syntax.
This commit is contained in:
parent
02e5f2aa10
commit
dfd9bdf633
|
@ -107,6 +107,9 @@ timeUnits = FuzzyDict({
|
||||||
def readTimeDelta(s):
|
def readTimeDelta(s):
|
||||||
"""convert a string like "2 days" or "1h2d3w" into seconds"""
|
"""convert a string like "2 days" or "1h2d3w" into seconds"""
|
||||||
# split number and words
|
# split number and words
|
||||||
|
if not s:
|
||||||
|
raise ValueError(s)
|
||||||
|
|
||||||
digit = string = number = None
|
digit = string = number = None
|
||||||
seconds = 0
|
seconds = 0
|
||||||
for c in s:
|
for c in s:
|
||||||
|
@ -137,6 +140,9 @@ def readTimeDelta(s):
|
||||||
string += c
|
string += c
|
||||||
|
|
||||||
# check last string
|
# check last string
|
||||||
|
if string is None:
|
||||||
|
raise ValueError(s)
|
||||||
|
|
||||||
if string.isdigit():
|
if string.isdigit():
|
||||||
seconds += int(string)
|
seconds += int(string)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -130,6 +130,8 @@ class BantrackerTestCase(ChannelPluginTestCase):
|
||||||
self.assertResponse('comment 1', 'No comments recorded for ban 1')
|
self.assertResponse('comment 1', 'No comments recorded for ban 1')
|
||||||
self.assertResponse('comment 1 this is a test', 'The operation succeeded.')
|
self.assertResponse('comment 1 this is a test', 'The operation succeeded.')
|
||||||
self.assertRegexp('comment 1', 'test: this is a test$')
|
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):
|
def testMultiComment(self):
|
||||||
self.feedBan('asd!*@*')
|
self.feedBan('asd!*@*')
|
||||||
|
|
Loading…
Reference in New Issue